Newsgroups: comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!satisfied.apocalypse.org!news.mathworks.com!hookup!remus.wat.hookup.net!thinkage.on.ca!dat
From: dat@thinkage.on.ca (David Adrien Tanguay)
Subject: Re: curried vs. tupled
Message-ID: <D5x8M3.9EL@thinkage.on.ca>
Sender: news@thinkage.on.ca
Organization: Thinkage Ltd., Kitchener, Ontario
References: <3kn8rt$fg3@agate.berkeley.edu> <3kqmbe$rg4@newsbf02.news.aol.com> <3ks4o5$jbq@agate.berkeley.edu>
Date: Fri, 24 Mar 1995 01:39:39 GMT
Lines: 34

bh@anarres.CS.Berkeley.EDU (Brian Harvey) writes:
>And we already have a special form that achieves the same purpose; it's
>called lambda.
>
>(define half (/ NULL 2))    <====>  (define half (lambda (x) (/ x 2)))

(define (curry f . args) (lambda rest (apply f (append args rest))))

(define (poof a b) (+ a b))
(define curried-poof-1 (curry poof 1))
(curried-poof-1 2) => 3

(define (lots a b c d) (+ a b c d))
(define curried-lots-2-3 (curry lots 2 3))
(curried-lots-2-3 4 5) => 14

Seems to work in scm.
Now, how do we do a vindaloo?

While I'm at it, here's one from the vaults:

(define (compose . f)
  (if (eq? f '())
    (lambda (a) a)
    (lambda (a) ((car f) ((apply compose (cdr f)) a)))))

(define (f a) (+ a 1))
(define (g a) (* a 2))
((compose f g) 1) => 3
((compose g f) 1) => 4
((compose f f g f) 2) => 8
-- 
David Tanguay       dat@Thinkage.on.ca     dat@Thinkage.com     thinkage!dat
Thinkage, Ltd.           Kitchener, Ontario, Canada          [43.24N 80.29W]
