From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Pascal J. Bourguignon" Newsgroups: gmane.emacs.help Subject: Re: Style Issues in Lisp and Scheme programming, setq versus let ... and onion structure with multiple cores or eyes or kernels Re: string to list or string to array Date: Wed, 21 Nov 2012 22:56:55 +0100 Organization: Informatimago Message-ID: <87a9uapql4.fsf@kuiper.lan.informatimago.com> References: <62642868-f757-4115-a047-34c319a1c30f@o5g2000yqi.googlegroups.com> <87pq4c848a.fsf@kuiper.lan.informatimago.com> <4e87f58c-72fc-457b-8596-c792c39472e5@m4g2000yqb.googlegroups.com> <87zk3f7ey7.fsf@kuiper.lan.informatimago.com> <657d823b-990f-4a2b-a57c-2c644099ddcd@z2g2000yqj.googlegroups.com> <492ccf3f-9658-4446-913e-3d0600011702@y8g2000yqy.googlegroups.com> <9b568902-c943-4b69-b80f-21f7fb0f814b@o8g2000yqh.googlegroups.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1353535220 30676 80.91.229.3 (21 Nov 2012 22:00:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 21 Nov 2012 22:00:20 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 21 23:00:31 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TbILP-0000rE-7L for geh-help-gnu-emacs@m.gmane.org; Wed, 21 Nov 2012 23:00:31 +0100 Original-Received: from localhost ([::1]:49660 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TbILB-0006JU-CP for geh-help-gnu-emacs@m.gmane.org; Wed, 21 Nov 2012 17:00:17 -0500 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help,comp.emacs,comp.lang.lisp,comp.lang.scheme Original-Lines: 47 Original-X-Trace: individual.net IyIQF8t6F7TTOXilsuhz6gHnaan4vpeRggwy2Otxm0XfOwbX8N5AbVvWHhzJ7z2WhQ Cancel-Lock: sha1:YzA2ZjE2ZjU5NTZmZDNlMTk2NWM3NmYwNDA0YzA4ODNhNGZmYjQ1Yg== sha1:MrQjaH8cPp0gZmIPt8DJzPK1XUM= Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Original-Xref: usenet.stanford.edu gnu.emacs.help:195513 comp.emacs:102706 comp.lang.lisp:311956 comp.lang.scheme:89282 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:87837 Archived-At: gnuist007@hotmail.com writes: > On Oct 24, 8:03 am, Stefan Monnier wrote: >> > btw, Lisp's prefix notation, (f x y z) is more expressive and >> > convenient for expressing currying (((f x) y) z) than f(x y z). >> >> With all due respect to Lisp, that's not true.  Curried calls in the >> non-Lisp syntax are simply "f(x)(y)(z)" or even better "f x y z". >> >>         Stefan > > As an aside you show the notation. well and good. But I realize that > there is no executable substitute or ability to return a curried > function > in emacs. Consider these forms. > > (+ 2 3 4) ;; executable > (((+ 2) 3) 4) ;; not executable > (cons '+ (cons 2 (cons 3 (cons 4 nil)))) ;; ditto > (eval '(+ (cons 2 (cons 3 (cons 4 nil))))) ;; ditto > > Can anyone suggest an executable version of first in terms of curried > addition? > > Since Pascal is busy, and David Kastrup is not seen for quite some > time, I hope someone can give a reply to the question of the thread. Well, if you want to keep the variadicity of the operation, it's hardly possible, because you can only return either a number or a function. In lisp, numbers are not applicable functions. Otherwise the following should work, in emacs-24: ;; in emacs-24: (setq lexical-binding t) (defun plus/2 (arg) (lambda (x) (+ arg x))) (defun plus/3 (arg) (lambda (y) (plus/2 (funcall (plus/2 arg) y)))) (funcall (plus/2 2) 3) --> 5 (funcall (plus/3 2) 3) --> # (funcall (funcall (plus/3 2) 3) 4) --> 9 -- __Pascal Bourguignon__ http://www.informatimago.com/ A bad day in () is better than a good day in {}.