Why is curry so limited?

For the Compleat Fan
Locked
Cyril
Posts: 183
Joined: Tue Oct 30, 2007 6:27 pm
Location: Moscow, Russia
Contact:

Why is curry so limited?

Post by Cyril »

Is it some reason why the curry function is limited to binary functions on input? Why not general any-arity to any-arity curry? This code seems to work well:

Code: Select all

(define (cu fun)
  (letex (Fun fun Args (args))
    (lambda () (apply Fun (append 'Args (args))))))

((cu + 1 2 3) 4 5) → 15

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

As an observer, my view is that most things in newLISP are designed with an eye to simplicity, speed, practicality, size, and conciseness. (Perhaps that should be 'concision', but I don't like that word! :-)) So the answer to many of your questions about the design of newLISP is going to be related to the way these criteria can be met.

I suspect, from reading this:

http://www.alh.net/newlisp/phpbb/viewtopic.php?t=1664

that the more basic *curry* filled most of the practical demands for curry quickly and speedily. You never know, a more extensive implementation may be on its way!

Cyril
Posts: 183
Joined: Tue Oct 30, 2007 6:27 pm
Location: Moscow, Russia
Contact:

Post by Cyril »

cormullion wrote:So the answer to many of your questions about the design of newLISP is going to be related to the way these criteria can be met.
Oh, yes, I must learn more about newlisp way. The problem is that I have too much previous mis-knowledge: I am fluent in both traditional scripting languages (perl, python) and traditional lisp (scheme), but newlisp is none of them. ;-) Right now I am converting some of my small python scripts to newlisp -- just to learn from experience. And I immediately found an usage for built-in curry:

Code: Select all

(map (curry format markup) cookies)
Good it is!

But now another question arises: why find-all, when nothing is found, returns nil and not empty list? I believe that this special case is not special enough: parse a line into tokens is a common pattern, and empty line is a common case in this pattern. In current state I must write:

Code: Select all

(dolist (word (or (find-all {pattern} (current-line)) '())) ...)
...and this seems awful. On the other hand, if you really want to check for "no match", '() serves as boolean as well as nil. Or I am missing something important again?

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

why find-all, when nothing is found, returns nil and not empty list?
'find-all' will be changed to return an empty list when nothing is found in the next development version.

Lutz

Cyril
Posts: 183
Joined: Tue Oct 30, 2007 6:27 pm
Location: Moscow, Russia
Contact:

Post by Cyril »

Lutz wrote:'find-all' will be changed to return an empty list when nothing is found in the next development version.
Oh. thank you! I'm I looking forward eagerly.

Locked