newLISP Fan Club

Forum => Anything else we might add? => Topic started by: Cyril on October 31, 2007, 06:57:29 PM

Title: Why is curry so limited?
Post by: Cyril on October 31, 2007, 06:57:29 PM
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:
(define (cu fun)
  (letex (Fun fun Args (args))
    (lambda () (apply Fun (append 'Args (args))))))

((cu + 1 2 3) 4 5) → 15
Title:
Post by: cormullion on November 01, 2007, 12:56:41 AM
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!
Title:
Post by: Cyril on November 02, 2007, 11:55:39 AM
Quote from: "cormullion"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:


(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:


(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?
Title:
Post by: Lutz on November 02, 2007, 01:16:43 PM
Quotewhy 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
Title:
Post by: Cyril on November 02, 2007, 02:09:42 PM
Quote from: "Lutz"'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.