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 : zipWith
<http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:zipWith>
xor2 xs bin


Notice how the definition of 'bin' is recursive.  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.

--
Mark J. Reed <markjr...@gmail.com>

Reply via email to