
"David Benbennick"
On 10/17/07, John Meacham
wrote: Oops, sorry, the version I posted was an intermediate one that had a different addition algorithm. here is a better one that fixes that issue:
Zero + y = y Sum x n1 + y = Sum x (y + n1)
note that it alternates the order in the recursive call, interleaving the elements of the two arguments.
Thanks.
Have you thought at all about how to make "maximally lazy" Naturals? For example, a data type that can answer True to both
genericLength (1:undefined) + genericLength (1:2:3:4:5:6:undefined) > (6 :: Nat)
genericLength (1:2:3:4:5:6:undefined) + genericLength (1:undefined) > (6 :: Nat)
Is that a desired feature?
It may be desirable, but it's not lambda definable, so you'd have to use concurrency to acheive it. -- Jón Fairbairn Jon.Fairbairn@cl.cam.ac.uk