Achim Schneider <[EMAIL PROTECTED]> wrote:

> (define (cons x y)
>    (lambda (m) (m x y)))
>  
> (define (car z)
>    (z (lambda (p q) p)))
> 
> (define (cdr z)
>    (z (lambda (p q) q)))
> 
, which, just for completeness, can be of course also be done in
Haskell:

cons :: a -> b -> (a -> b -> c) -> c
cons x y m = m x y

car :: ((a -> b -> a) -> c) -> c 
car z = z $ \p q -> p

cdr :: ((a -> b -> b) -> c) -> c
cdr z = z $ \p q -> q

Prelude> car $ cdr $ cdr $ cons 1 $ cons 2 $ cons 3 ()
3


-- 
(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
signature prohibited. 

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to