Lazy Lists in Python and C++
nonchalantlytyped.net
nonchalantlytyped.net
This code isn't very well factored, but I think the results are pretty clean looking. With this code:
: printPair ." ( " . ." , " . ." )" space ;
1 2 counter 0 5 range zip 1 2 counter 3 7 range zip chain ' printPair map
You get this output: ( 0 , 1 ) ( 1 , 3 ) ( 2 , 5 ) ( 3 , 7 ) ( 4 , 9 ) ( 5 , 11 )
( 3 , 1 ) ( 4 , 3 ) ( 5 , 5 ) ( 6 , 7 ) ( 7 , 9 )