[ANN] LazyList version 5

J J azreal1977 at hotmail.com
Sun Apr 29 15:04:00 UTC 2007


Hello all,

I recently published a new version of the LazyList package on SqueakSource.

New in this release:

Changed the name of LazyElement to LazyList to prevent confusion.
Added merge method (see below).
Added lots of tests (I think all the functionality is pretty well covered).

The merge method is the merge step of the merge sort algorithm (given two 
sorted lists, it efficiently merges them into one sorted list).

To give an idea of what one might use it for, I will give my reason for 
adding it:  I use LazyLists to generate recurrence rules for ICal events.  
The events themselves are allowed to have 0 or more recurrence rules (each 
generating a potentially endless list of dates).  The interface I provide 
allows the client to specify how many events he would like to consume.

But before it was difficult to pull the right amount when there is more then 
one rule, since the ordering is not predictable (e.g. one rule may return an 
event for every second and the next one event for every 10th year).  Now 
with the merge function I can simply do:

dates := rules first events.

rules allButFirst do: [:rule| dates := dates merge: rule events ].

^ dates take: numberRequested

In this way, we never generate more required (well actually there will be 
one extra from each rule for the sort comparison, but no more), and so long 
as the events method returns a sorted set the dates returned will be sorted.

If anyone uses it and sees any problems let me know. :)

Thanks,
Jason

_________________________________________________________________
MSN is giving away a trip to Vegas to see Elton John.  Enter to win today. 
http://msnconcertcontest.com?icid-nceltontagline




More information about the Squeak-dev mailing list