smalltalk - how to stream a collection backwards without copies? -


i know how stream collection backwards without copies in pharo/squeak.

for example, stream #(1 2 3) stream next returns 3, 2, 1. know use collection reversed readstream, reversed copies.

you use generator:

| coll stream | coll := #(1 2 3). stream := generator on: [:g | coll reversedo: [:ea | g yield: ea]]. stream next 

generators let wrap streaming interface around piece of code, basically.


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -