Hi, > Essentially lazy lists are suspended closures. But I dought that > arithmetic between them is defined such that pi + pi would leazily > calculate 6.28...
...which makes me wonder if it'd be good|cool|whatever to not only have lazy lists, but also lazy *values*...: :)) my $pi = calc_pi_lazily(); say substr $pi, 0, 5; # calculates and outputs the # first five digits of pi say substr $pi, 0, 10000000; # calculates and outputs # digits 0 to 10000000-1 of pi my $sum = $pi * 2 + calc_e_lazily(); say substr $sum, 0, 100; # calculates and outputs the # first 99 digits of 2pi + e (Internally, this $pi could just be a Num::Lazy which hasa lazy @.digits and which has an appropriate MMD entry for substr. But this is an implementation detail.) And: my @ones = gather { take 1 while 1 }; my $ones = join "", @ones; # does not burn out! say length $ones; # Inf :) --Ingo -- Linux, the choice of a GNU | Memorize 1000 digits of pi generation on a dual AMD | http://theory.cs.iitm.ernet.in/~arvindn/pi/ Athlon! |