On Tue, 2009-05-26 at 18:36 -0500, Eduardo Cavazos wrote:
Hello,
> 
> Here's a simple procedure:
> 
> (define (subtract-from n)
>     (lambda (m)
>       (- n m)))
> 
> subtract-from is essentially a two parameter '-' which is curried,
left
> to right.
> 
> I don't recall a traditional/defacto way to express this. Any ideas or
> suggestions?

I've always liked the traditional extended define:

(define-syntax define*
  (syntax-rules ()
    ((_ ((x . f1) . f2) . b)
     (define* (x . f1)
       (lambda f2 . b)))
    ((_ . r)
     (define . r))))

> (define* ((subtract-from n) m)
    (- n m))
> ((subtract-from 10) 4)
6
> (define* ((((f a b) c) d e f) . r)
    (apply + a b c d e f r))
> ((((f 1 2) 3) 4 5 6) 7 8 9 10 11 12 13)
91
> (define* (((g a . r0) b . r1) c . r3)
    (list a r0 b r1 c r3))
> (((g 1 2) 3 4 5) 6 7 8 9)
(1 (2) 3 (4 5) 6 (7 8 9))
>

-- 
: Derick
----------------------------------------------------------------

Reply via email to