mwatts15 / Crono

Scheme project for CS345
0 stars 0 forks source link

Preload whole number combinators into the environment #6

Closed mwatts15 closed 11 years ago

cvidal commented 11 years ago

Combinators should be correct. They follow their traditional definitions in lambda calculus, which sometimes doesn't work in crono (namely, the K combinator doesn't work without currying).

The Y combinator is the traditional definition of the Y combinator, which works with call-by-name languages. If you need to use the Y combinator, use the Z combinator instead. They are functionally equivalent, but the Z combinator works with call-by-value languages like ours.

Try this:

(load ../prelude.lisp) 
(let ((fact  
      (<Z> 
             (\ (f) 
             (\ (n) 
                (if (= n 0) 
                1 
                (* n (f (- n 1))))))))) 
    (fact 3))