Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Associativity paradox in functional expressions
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  14 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Totaram Sanadhya  
View profile  
 More options Oct 31 2012, 3:24 am
Newsgroups: comp.lang.functional, comp.lang.lisp, comp.lang.scheme, comp.programming, comp.emacs
From: Totaram Sanadhya <swami.totaram.sanad...@gmail.com>
Date: Wed, 31 Oct 2012 00:24:32 -0700 (PDT)
Local: Wed, Oct 31 2012 3:24 am
Subject: Re: Associativity paradox in functional expressions
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?

Swami


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Barb Knox  
View profile  
 More options Oct 31 2012, 4:14 am
Newsgroups: comp.lang.functional, comp.lang.lisp, comp.lang.scheme, comp.programming, comp.emacs
From: Barb Knox <s...@sig.below>
Date: Wed, 31 Oct 2012 21:14:22 +1300
Local: Wed, Oct 31 2012 4:14 am
Subject: Re: Associativity paradox in functional expressions
In article
<9972e570-2504-4401-8de8-49eb1929f...@c17g2000yqe.googlegroups.com>,
 Totaram Sanadhya <swami.totaram.sanad...@gmail.com> wrote:

Easily:  Lisp does not use curried functions.

> Swami

--
---------------------------
|  BBB                b    \     Barbara at LivingHistory stop co stop uk
|  B  B   aa     rrr  b     |
|  BBB   a  a   r     bbb   |    Quidquid latine dictum sit,
|  B  B  a  a   r     b  b  |    altum videtur.
|  BBB    aa a  r     bbb   |  
-----------------------------

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nils M Holm  
View profile  
 More options Oct 31 2012, 5:21 am
Newsgroups: comp.lang.functional, comp.lang.lisp, comp.lang.scheme, comp.programming, comp.emacs
Followup-To: comp.lang.scheme
From: Nils M Holm <news2...@t3x.org>
Date: 31 Oct 2012 09:21:23 GMT
Local: Wed, Oct 31 2012 5:21 am
Subject: Re: Associativity paradox in functional expressions
In comp.lang.scheme Totaram Sanadhya <swami.totaram.sanad...@gmail.com> wrote:

> 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?

It depends.

How do you obtain the curried F in the above expression?

What is (curry (curry cons x) y) supposed to give?

What exactly is the paradox?

Maybe, it would be helpful if you posted some code that
demonstrates what you are trying to do.

F'up-To: comp.lang.scheme

--
Nils M Holm  < n m h @ t 3 x . o r g >  www.t3x.org


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Totaram Sanadhya  
View profile  
 More options Oct 31 2012, 1:34 pm
Newsgroups: comp.lang.functional, comp.lang.lisp, comp.lang.scheme, comp.programming, comp.emacs
From: Totaram Sanadhya <swami.totaram.sanad...@gmail.com>
Date: Wed, 31 Oct 2012 10:34:04 -0700 (PDT)
Local: Wed, Oct 31 2012 1:34 pm
Subject: Re: Associativity paradox in functional expressions
On Oct 31, 1:14 am, Barb Knox <s...@sig.below> wrote:

Which programming languages use curried functions?

I have often heard people like Kastrup talk of
curried functions in gnu.emacs.help and they
even give some code like

((lambda(g n) (funcall g g n))
 (lambda(f n)
   (if (zerop n) 1
     (* n (funcall f f (1- n)))))
 4 )

Is there some kind of hack by which I could come close to it in emacs
lisp?

I would have gladly put a backtrace or execution trace for you, but I
could not find a single function that gives an output like the
detailed backtrace when there is an execution error. Perhaps, someone
who is more knowledgeable can take this as an _aside_ question.

However, before I end my post, I just want to thank both Barb and
especially Nils for his student-friendly writings, and the wonderful
books he has written.

Swami

P.S. Unfortunately, I have to crosspost as this is relevant in many
groups, so please avoid or ignore any flames or derailing attempts.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dirk Thierbach  
View profile  
 More options Oct 31 2012, 6:36 pm
Newsgroups: comp.lang.functional, comp.lang.lisp, comp.lang.scheme, comp.programming, comp.emacs
Followup-To: comp.lang.functional
From: Dirk Thierbach <dthierb...@usenet.arcornews.de>
Date: Wed, 31 Oct 2012 23:36:11 +0100
Local: Wed, Oct 31 2012 6:36 pm
Subject: Re: Associativity paradox in functional expressions

Totaram Sanadhya <swami.totaram.sanad...@gmail.com> wrote:
> On Oct 31, 1:14 am, Barb Knox <s...@sig.below> wrote:
>> Easily:  Lisp does not use curried functions.
> Which programming languages use curried functions?

The original lambda calculus, Haskell, OCaml, I think the whole ML family ...

On the other hand, these languages don't depend on lists for program
code.

[F'up to c.l.f.]

- Dirk


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pascal J. Bourguignon  
View profile  
 More options Nov 2 2012, 9:45 am
Newsgroups: comp.lang.functional, comp.lang.lisp, comp.lang.scheme, comp.programming, comp.emacs
From: "Pascal J. Bourguignon" <p...@informatimago.com>
Date: Fri, 02 Nov 2012 14:45:19 +0100
Local: Fri, Nov 2 2012 9:45 am
Subject: Re: Associativity paradox in functional expressions

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__


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rivka Miller  
View profile  
 More options Nov 2 2012, 9:59 pm
Newsgroups: comp.lang.functional, comp.lang.lisp, comp.lang.scheme, comp.programming, comp.emacs
From: Rivka Miller <rivkaumil...@gmail.com>
Date: Fri, 2 Nov 2012 18:59:48 -0700 (PDT)
Local: Fri, Nov 2 2012 9:59 pm
Subject: Re: Associativity paradox in functional expressions
On Nov 2, 6:45 am, "Pascal J. Bourguignon" <p...@informatimago.com>
wrote:

@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.

(defun lons (prefix item)
       (append prefix (list item)))

(lons (lons (lons (lons nil 'a) 'b) 'c) 'd)

(lons (lons (lons '(f) 'x) 'y) 'z)

;; clarifies the meaning of lons by Pascal
(append (append (append (append nil (list 'a)) (list 'b)) (list 'c))
(list 'd))

;; clarifies the role of append
(append '(a b) '(c (d) e))

R


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pascal J. Bourguignon  
View profile  
 More options Nov 2 2012, 11:14 pm
Newsgroups: comp.lang.functional, comp.lang.lisp, comp.lang.scheme, comp.programming, comp.emacs
From: "Pascal J. Bourguignon" <p...@informatimago.com>
Date: Sat, 03 Nov 2012 04:14:04 +0100
Local: Fri, Nov 2 2012 11:14 pm
Subject: Re: Associativity paradox in functional expressions

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rivka Miller  
View profile  
 More options Nov 5 2012, 7:53 pm
Newsgroups: comp.lang.functional, comp.lang.lisp, comp.lang.scheme, comp.programming, comp.emacs
From: Rivka Miller <rivkaumil...@gmail.com>
Date: Mon, 5 Nov 2012 16:53:16 -0800 (PST)
Local: Mon, Nov 5 2012 7:53 pm
Subject: Re: Associativity paradox in functional expressions
On Nov 2, 7:14 pm, "Pascal J. Bourguignon" <p...@informatimago.com>
wrote:

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
available?

((lambda(g n) (funcall g g n))
 (lambda(f n)
   (if (zerop n) 1
     (* n (funcall f f (1- n)))))
 4 )

R


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pascal J. Bourguignon  
View profile  
 More options Nov 6 2012, 1:28 am
Newsgroups: comp.lang.functional, comp.lang.lisp, comp.lang.scheme, comp.programming, comp.emacs
From: "Pascal J. Bourguignon" <p...@informatimago.com>
Date: Tue, 06 Nov 2012 07:28:47 +0100
Local: Tues, Nov 6 2012 1:28 am
Subject: Re: Associativity paradox in functional expressions

Rivka Miller <rivkaumil...@gmail.com> writes:
> 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?

Yes.  John McCarthy didn't understand lambda calculus at the time. He
just used the lambda notation for his functions, but they differed
greately, notably  in that he used dynamic binding instead of lexical
binding.

> 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
> available?

> ((lambda(g n) (funcall g g n))
>  (lambda(f n)
>    (if (zerop n) 1
>      (* n (funcall f f (1- n)))))
>  4 )

Well, in lisp there are parentheses to imply the order of evaluation…

--
__Pascal Bourguignon__
http://www.informatimago.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Barb Knox  
View profile  
 More options Nov 7 2012, 11:36 pm
Newsgroups: comp.lang.functional, comp.lang.lisp, comp.lang.scheme, comp.programming, comp.emacs
From: Barb Knox <s...@sig.below>
Date: Thu, 08 Nov 2012 17:35:58 +1300
Local: Wed, Nov 7 2012 11:35 pm
Subject: Re: Associativity paradox in functional expressions
In article <87ip9j8ctc....@informatimago.com>,
 "Pascal J. Bourguignon" <p...@informatimago.com> wrote:

> Rivka Miller <rivkaumil...@gmail.com> writes:

> > 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?

Lambda calculus supports currying.  Lisp is not lambda calculus.

> Yes.  John McCarthy didn't understand lambda calculus at the time. He
> just used the lambda notation for his functions

Yeah right.  McCarthy had a PhD in mathematics and specialised in
mathematical logic; of course he knew lambda calculus.  Or do you
believe his use of "lambda" was just a coincidence?  In his1960  paper
introducing LISP ("Recursive Functions of Symbolic Expressions and Their
Computation by Machine"
<http://www-formal.stanford.edu/jmc/recursive.html>), one of his
references is Church's 1941 paper on the lambda calculus.

Are you a moron?  Is that why you have such a self-aggrandising nickname?

[snip]

--
---------------------------
|  BBB                b    \     Barbara at LivingHistory stop co stop uk
|  B  B   aa     rrr  b     |
|  BBB   a  a   r     bbb   |    Quidquid latine dictum sit,
|  B  B  a  a   r     b  b  |    altum videtur.
|  BBB    aa a  r     bbb   |  
-----------------------------


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aatu Koskensilta  
View profile  
 More options Nov 8 2012, 12:40 am
Newsgroups: comp.lang.functional, comp.lang.lisp, comp.lang.scheme, comp.programming, comp.emacs
From: Aatu Koskensilta <aatu.koskensi...@uta.fi>
Date: Thu, 08 Nov 2012 07:42:33 +0200
Local: Thurs, Nov 8 2012 12:42 am
Subject: Re: Associativity paradox in functional expressions

Barb Knox <s...@sig.below> writes:
> In article <87ip9j8ctc....@informatimago.com>,
>  "Pascal J. Bourguignon" <p...@informatimago.com> wrote:

>> Yes.  John McCarthy didn't understand lambda calculus at the time. He
>> just used the lambda notation for his functions

> Yeah right.  McCarthy had a PhD in mathematics and specialised in
> mathematical logic; of course he knew lambda calculus.  Or do you
> believe his use of "lambda" was just a coincidence?

  Naturally McCarthy got the lambda notation from lambda
calculus. McCarthy was not a mathematical logician by any stretch of the
imagination -- his research was mainly in computer science, artificial
intelligence in particular, and his PhD dissertation was on a problem in
partial differantial equations -- and had this to say about the state of
his understanding of the lambda calculus at the time:

   To use functions as arguments, one needs a notation for functions,
   and it seemed natural to use the lambda-notation of Church (1941). I
   didn't understand the rest of the book, so I wasn't tempted to
   implement his more general mechanism for defining functions.

This excerpt is from McCarthy's /History of Lisp/, available on-line at:

   http://www-formal.stanford.edu/jmc/history/lisp.ps

> Are you a moron?  Is that why you have such a self-aggrandising
> nickname?

  You think "Pascal J. Bourguignon" a "self-aggrandising nickname"?

--
Aatu Koskensilta (aatu.koskensi...@uta.fi)

"Wovon man nicht sprechen kann, darüber muss man schweigen"
  - Ludwig Wittgenstein, Tractatus Logico-Philosophicus


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pascal J. Bourguignon  
View profile  
 More options Nov 8 2012, 3:47 pm
Newsgroups: comp.lang.functional, comp.lang.lisp, comp.lang.scheme, comp.programming, comp.emacs
From: "Pascal J. Bourguignon" <p...@informatimago.com>
Date: Thu, 08 Nov 2012 21:47:53 +0100
Local: Thurs, Nov 8 2012 3:47 pm
Subject: Re: Associativity paradox in functional expressions

Aatu Koskensilta <aatu.koskensi...@uta.fi> writes:
> Barb Knox <s...@sig.below> writes:
>> Are you a moron?  Is that why you have such a self-aggrandising
>> nickname?

>   You think "Pascal J. Bourguignon" a "self-aggrandising nickname"?

"informatimago" would be the nickname.  It means Software Sorcerer.
Yes, perhaps it's self aggrandising.  You have to forgive it, I chosed
it when I was much younger.  Software Sorcerer was a name we took with a
friend in 1984, when I was barely 20, with SOS\000 to SOS\377 having
been registered as MacOS application signatures with Apple Computer.
Unfortunately we split out before finishing our developments, and each
went his way.  Eventually I moved to Spain and registered the
informatimago.com domain name on 25-may-2001.  I was probably influenced
by those early memories and by sicp.

--
__Pascal Bourguignon__
http://www.informatimago.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Barb Knox  
View profile  
 More options Nov 9 2012, 9:13 pm
Newsgroups: comp.lang.functional, comp.lang.lisp, comp.lang.scheme, comp.programming, comp.emacs
From: Barb Knox <s...@sig.below>
Date: Sat, 10 Nov 2012 15:13:20 +1300
Local: Fri, Nov 9 2012 9:13 pm
Subject: Re: Associativity paradox in functional expressions
In article <87zk2sabw6....@uta.fi>,
 Aatu Koskensilta <aatu.koskensi...@uta.fi> wrote:

Oops.  I confused it with "Harrison Bergeron".  My bad.  And I withdraw
the "moron" semi-rhetorical question.

--
---------------------------
|  BBB                b    \     Barbara at LivingHistory stop co stop uk
|  B  B   aa     rrr  b     |
|  BBB   a  a   r     bbb   |    Quidquid latine dictum sit,
|  B  B  a  a   r     b  b  |    altum videtur.
|  BBB    aa a  r     bbb   |  
-----------------------------


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »