next up previous contents
Next: Extensible Collections Up: Collections Previous: Making new collections   Contents

Iterating

do:
executes a block with :each (the idiomatic input slot for iterating) of the collection's elements in turn. It answers the original collection.
collect:
also takes a block, but answers a collection with all the results of those block-applications put into a new collection of the appropriate type.
select:
takes a block that answers a Boolean and answers a new collection of the elements that the block filters (answers True).
reject:
performs the logical opposite of select:, answering elements for which the block answers False.
inject: init into: accumulator
takes a two-argument accumulation block and applies it across the collection's elements. The initial value given becomes the first argument, and is replaced through the iterations with the result of the block.
reduce:
takes a two-argument block and performs the same action as inject:into: only using one of the collection's elements as an initial value.



Brian Rice 2004-08-24