Message from discussion Associativity paradox in functional expressions
Received: by 10.224.186.20 with SMTP id cq20mr6865673qab.8.1352163196326;
Mon, 05 Nov 2012 16:53:16 -0800 (PST)
Received: by 10.52.37.12 with SMTP id u12mr1855144vdj.8.1352163196302; Mon, 05
Nov 2012 16:53:16 -0800 (PST)
Date: Mon, 5 Nov 2012 16:53:16 -0800 (PST)
Injection-Info: x21g2000vbg.googlegroups.com; posting-host=220.127.116.11; posting-account=V5Tx-QoAAACNTDxOswIwdOklJAUE-vym
X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 5.1; rv:12.0) Gecko/20100101 Firefox/12.0,gzip(gfe)
Subject: Re: Associativity paradox in functional expressions
From: Rivka Miller <rivkaumil...@gmail.com>
Injection-Date: Tue, 06 Nov 2012 00:53:16 +0000
Content-Type: text/plain; charset=windows-1252
On Nov 2, 7:14=A0pm, "Pascal J. Bourguignon" <p...@informatimago.com>
> Rivka Miller <rivkaumil...@gmail.com> writes:
> > On Nov 2, 6:45=A0am, "Pascal J. Bourguignon" <p...@informatimago.com>
> > wrote:
> >> Totaram Sanadhya <swami.totaram.sanad...@gmail.com> 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)))) =A0 =A0C-x C-e
> >> > =3D=3D> (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.
> >> =A0 =A0 (defun lons (prefix item)
> >> =A0 =A0 =A0 =A0(append prefix (list item)))
> >> =A0 =A0 (lons (lons (lons (lons nil 'a) 'b) 'c) 'd)
> >> =A0 =A0 --> (a b c d)
> >> =A0 =A0 (lons (lons (lons '(f) 'x) 'y) 'z)
> >> =A0 =A0 --> (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. =A0Currying is a notion that is only
> needed when you have function taking only one argument.
> Now, =A0you may write a macro that implements some currying. =A0In such a
> macro, you would use lons instead of cons=85
Are you saying that the Late Dr McCarthy, after thinking of lisp in
terms of lambda calculus (and its associated currying), nevertheless
implemented it in terms of variadic non-curried functions? Thus the
turing machine replacement that lambda calculus is supposed to be,
does not need any currying to be a replacement of turing machine - in
the sense of computability?
How would the "(funcall g g n)" and "(funcall f f (1- n))" in the
function advanced by the OP supposed to be associated if currying were
((lambda(g n) (funcall g g n))
(if (zerop n) 1
(* n (funcall f f (1- n)))))