Hi!

No stress is good news!

- what is the API in terms of vocabulary (ie drop the same as reject)

These are the operations implemented so far. |= means "satisfies", i.e., evaluate to true.

Drop          drop first n elements
DropWhile     drop first elements |= a block
Filter*       pick only elements |= a block
Keep*         only use elements ~= nil
Map*          map each element
MapKeys*      map each element an use as key
Partition     split after n elements
PartitionBy   split after elements |= a block
RandomSample* pick elements with probability p
Reductions    intermediate results of reduce
Remove*       = Filter not
Replace*      replace elements by LUT
Cat*          concatenate sequences
Dedupe        remove consecutive duplicates
Flatten*      flatten nested sequence
Take          pick first n elements
TakeNth       pick every n-th element
TakeWhile     pick first elements |= a block
Tee           UNIX tee, concurrent evaluation

Note, * means that the operation is parallelizable. As the operations are independent of the sequence class, the apply naturally to all kinds of sources, like collections, streams, channels and so on.

- can we reexpress some of our iterators?

Most of them. For example, generic for all collections:

collect: aBlock
  ^self class <~ aBlock map <~ self
reject: aBlock
  ^self class <~ ablock remove <~ self
select: aBlock
  ^self class <~ aBlock filter <~ self

As said before, names are not fixed yet and there is a more classical API on top available, too:

collect: aBlock
  ^(self transduce map: aBlock) into: self class

- what is the cost?

Very little. In detail:
1) Upfront there is the constant cost of instantiating the tranducers.
2) The linear cost of evaluating a nested block for each element. This is likely to be optimized by the JIT, as the structure is very regular.

I only did some micro-benchmarks which showed little to none impact on performance so far.

Best,
Steffen

Reply via email to