[plt-scheme] Currying functions?
On Feb 4, Doug Orleans wrote:
> Gregory Woodhouse writes:
> > Maybe it's possible to create a curried version of a
> > function taking a variable number of arguments, but I'm not sure how
> > it would be done.
>
> I don't think it makes sense to "fully" curry a varargs procedure.
> Which of these should return numbers, and which should return procedures?
>
> (curry +)
> ((curry +) 1)
> (((curry +) 1) 2)
> ((((curry +) 1) 2) 3)
See the code I sent -- it had an example of `curry' being the
operation that creates the curried function given some arguments. The
you get
(curry +) == +
(curry + 1) == (lambda xs (apply + 1 xs))
(curry + 1 2) == (lambda xs (apply + 1 2 xs))
and you can use multiple `curry's to add more levels. This seems like
the only reasonable approach for arity-at-least-0 functions.
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://www.barzilay.org/ Maze is Life!