Re: l, the ultimate curry that is not curry
Al Petrofsky 25 Feb 2002 22:10 UTC
> From: xxxxxx@philips.com
> you can find examples where it is an advantage to drop the
> actual names of the variables, especially if they are longer.
> The break even point comes when
>
> Sum(n[i] : i in {1..r}) >= r,
>
> where n[i] is the number of characters in the name of the
> i-th parameter of the result, for i in {1..r}. In other
> words, the 'curry'-notation is shorter when there is at
> least one variable name with more than one character.
> For example,
>
> (curry cons-stream <> stream)
> <=> (l (object stream) (cons-stream object stream))
Actually, that would be:
(curry cons-stream <> stream)
<=> (l (object) (cons-stream object stream))
But if it is not important to give the argument a descriptive name in
the curry version, then it is not important in the lambda version
either, so we have:
(curry cons-stream <> stream)
<=> (l (x) (cons-stream x stream))
As you can see, curry's character count advantage is negligible (one
character per "<>").
-al
P.S. The procedural implementation of curry would choke on this
example, if we assume the usual definition of cons-stream (a macro
that delays its second argument).