Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!nuzba.szn.dk!pnx.dk!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: Fri, 02 Nov 2012 14:45:19 +0100 Organization: Informatimago Lines: 36 Message-ID: <87pq3wqftc.fsf@voyager.informatimago.com> References: <8120f97b-15c2-4ce8-827a-158e955fb73f@z2g2000yqj.googlegroups.com> <9972e570-2504-4401-8de8-49eb1929fdfd@c17g2000yqe.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: individual.net Qz5czpSTSZq0Q9O3MTJN0ArBgukAke/upEaREAunaTcWrIIriRUAhKDVGUtK+wWUmK Cancel-Lock: sha1:MmRkMjQ1ZjRlNGY0ZTE5OWMzMTk2NzhlN2QzOTA2Y2Q3NzYyYWE1Yg== sha1:Z1DnXatAhd32P7KXhY636D2E4SY= 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.2 (gnu/linux) Xref: csiph.com comp.lang.functional:439 comp.lang.lisp:11880 comp.lang.scheme:1118 comp.programming:2439 comp.emacs:1607 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 leflt-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 Bourguignon__