Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.szaf.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Pascal J. Bourguignon" Newsgroups: comp.lang.functional,comp.lang.lisp,comp.lang.scheme,comp.programming,comp.emacs Subject: Re: Associativity paradox in functional expressions Date: Sat, 03 Nov 2012 04:14:04 +0100 Organization: Informatimago Lines: 55 Message-ID: <87liejml8j.fsf@informatimago.com> References: <8120f97b-15c2-4ce8-827a-158e955fb73f@z2g2000yqj.googlegroups.com> <9972e570-2504-4401-8de8-49eb1929fdfd@c17g2000yqe.googlegroups.com> <87pq3wqftc.fsf@voyager.informatimago.com> <3dd68e98-9889-4287-a352-3c7c25a3284e@d17g2000vbv.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net 1xEhI1US22ncfrIj+6Y0iQZ0Qa90WTCM6gnmR9D19XSuQZBVJlTqtRDCcVS/NGIi/n Cancel-Lock: sha1:MTYxMTA0ZDUwMDg3YjUwNzdlNzE1YWE3M2IxNDFmNDhlN2NkY2FlNQ== sha1:TUIjbUBn7/cExzJb4WNxPMjSZwE= 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 (darwin) Xref: csiph.com comp.lang.functional:443 comp.lang.lisp:11896 comp.lang.scheme:1121 comp.programming:2443 comp.emacs:1611 Rivka Miller writes: > On Nov 2, 6:45 am, "Pascal J. Bourguignon" > wrote: >> Totaram Sanadhya writes: >> > Hi, >> >> > My main functional language is emacs based lisp. >> >> > I am not exactly clear about the associativity. >> >> > On the one hand the elements of a list such as (a b c d) are right >> > associative >> >> > (cons 'a (cons 'b (cons 'c (cons 'd nil))))    C-x C-e >> >> > ==> (a b c d) >> >> > On the other hand a curried function such as (f x y z) is left >> > associative by definition >> >> > (...(f x) y) z) >> >> > How do you resolve this paradox? >> >> By defining a left-associative function. >> >>     (defun lons (prefix item) >>        (append prefix (list item))) >> >>     (lons (lons (lons (lons nil 'a) 'b) 'c) 'd) >>     --> (a b c d) >> >>     (lons (lons (lons '(f) 'x) 'y) 'z) >>     --> (f x y z) > > @Pascal > > I did not get what you achieved by defining a left-associative > function. Your sentence did not clarify your thought. I dont see where > is currying achieved. Currying is not achieved, there's no currying in lisp, lisp has multi-adic and variadic functions. Currying is a notion that is only needed when you have function taking only one argument. Now, you may write a macro that implements some currying. In such a macro, you would use lons instead of cons… -- __Pascal Bourguignon__ http://www.informatimago.com