[racket] Making a Racket function "recallable"

From: Danny Yoo (dyoo at cs.wpi.edu)
Date: Tue Feb 14 00:20:37 EST 2012

>  (let ([fib-sequence (in-producer fib 'donttellmecauseithurts)])

I realize that I forgot to add explanation.

This line creates a "sequence" by repeatedly calling your fib
function. in-producer will continue to call fib until it sees the
second argument.  But since the fibonacci numbers don't end, I want to
tell in-producer to go on forever, so I passed it something that fib
won't ever produce.

... and It's from a song by the music group No Doubt.  Why?  Dunno.
Valentine's Day brought it to mind for some reason.  :)

The second part:

  ;; Let's wrap it and turn it into a stream that remembers...
   (sequence->stream fib-sequence)

turns the sequence into another sequence.  But this one will remember
its previous values as we walk across it.

So when we do start walking the streamified sequence, we can do that
repeatedly without losing the old values.

Posted on the users mailing list.