Sequential Consequences
stuartsierra.com
stuartsierra.com
weeell, maybe. I'm relearning a language I haven't touched for years, and while I can apply the high-level stuff to it (I know what an object is, how to declare a class is almost universal, functional stuff is same but renamed, generics are fine) I keep tripping over the small stuff. So yes, "off you go", but rather slowly.
things, also_things = itertools.tee(things)
next(things), list(also_things)
=> (0, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])But if the original `things` is gigabytes in size and streamed from elsewhere, isn't it queueing those all up, as they're read from `also_things`, in case they're ever read from new `things` - even if they're not?
Update: googled up memoizator that almost imlements exactly what I'm talking about: http://code.activestate.com/recipes/577992-memoize-generator...
Just add __getitem__() to it that would access __cache, and you're done.
F# has Seq.Cache so the the seq stays lazy but only remembers what has come in the "past", mimicking the Clojure behavior if you want to opt-in -- I'm not sure there's a corresponding BCL fn yet for C#.