Recursive lazy lists?

2011-07-30 Thread Mark J. Reed
Sorry if this has come up before and I missed it, but I just came across this Haskell function to convert from Gray code back to normal binary (as lists of 1s and 0s; full code at http://rosettacode.org/mw/index.php/Gray_code#Haskell): gray2bin [] = [] gray2bin (x:xs) = bin where bin = x : zipWi

Re: Recursive lazy lists?

2011-07-30 Thread Bruce Gray
On Jul 30, 2011, at 8:30 AM, Mark J. Reed wrote: --snip-- Does Perl6's variety of laziness support this sort of definition? It's not an infinite list; zipWith stops zipping as soon as either list is empty. But the self-reference in the definition means it still has to be computed lazily.

Re: Recursive lazy lists?

2011-07-30 Thread Mark J. Reed
On Sat, Jul 30, 2011 at 6:02 PM, Bruce Gray wrote: > > Yes, Perl 6 does support laziness in this sort of definition, via "run-time > binding". > Very cool. Thanks! > Here is a quick conversion of the Haskell solution into Perl 6; its output > (when run in Rakudo) exactly matches the output of

Re: Recursive lazy lists?

2011-07-30 Thread Bruce Gray
On Jul 30, 2011, at 6:40 PM, Mark J. Reed wrote: On Sat, Jul 30, 2011 at 6:02 PM, Bruce Gray wrote: --snip-- our multi sub infix: ( $x, $y ) { ( $x + $y ) % 2 }; Why did you need to define this yourself instead of just using +^ ? Umm, because that is what was done in the Haskell code I