[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: l, the ultimate curry that is not curry

This page is part of the web mail archives of SRFI 26 from before July 7th, 2015. The new archives for SRFI 26 contain all messages, not just those from before July 7th, 2015.



> From: sebastian.egner@xxxxxxxxxxx

> 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).