lunes, 26 de abril de 2010

Iterator::Simple, as simple as it gets

We're all feeling spring is coming again. That's not new though, so you could have guessed that after winter, spring was about to come.. ¬¬

We could build a circular list to retrieve a list of consecutive seasons, but as I discovered
Iterator::Simple, Here follows a stupid example of its usage.



We can also wrap an iterator, "á la" stream (I'm reading the stream chapter in SICP, and nowadays, I can only think in streams :p ), delaying the evaluation of the wrapping until the given elements are needed using imap. We also have ifilter, igrep, and so.

Here's a code that wraps (or decorates, in python slang IIRC) our iterator modifying the string returned, and it limits the iterator to 6 seasons.