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?

In some older code of mine, I used the following notation:

(define (curry/ab procedure)
  (lambda (a)
    (lambda (b)
      (procedure a b))))

(define (curry/ba procedure)
  (lambda (b)
    (lambda (a)
      (procedure a b))))

The 'ab' indicates that there are two parameters. The order indicates
the order that they are specialized.

I had other variations:

(define (curry/a:bc procedure)
  (lambda (a)
    (lambda (b c)
      (procedure a b c))))

"specialize a, then b and c simultaneously"

(define (curry/b:ac procedure)
  (lambda (b)
    (lambda (a c)
      (procedure a b c))))

"specialize b, then a and c simultaneously"

(define (curry/an procedure)
  (lambda (a)
    (lambda args
      (apply procedure a args))))

"specialize a, then any number of args"

Related:

(define (partial-apply/ab procedure a)
  (lambda (b)
    (procedure a b)))

(define (partial-apply/ba procedure b)
  (lambda (a)
    (procedure a b)))

Anywho, 'subtract-from' would be:

    (define subtract-from (curry/ab -))

Ed

Reply via email to