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
identity
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
  5 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
 
time  
View profile  
 More options Nov 5 2011, 5:45 pm
Newsgroups: comp.lang.scheme
From: time <timreve...@gmail.com>
Date: Sat, 5 Nov 2011 14:45:21 -0700 (PDT)
Local: Sat, Nov 5 2011 5:45 pm
Subject: identity
What is the rational for returning the identity for expressions such as (*) and (+)?

Thanks!


 
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 Costanza  
View profile  
 More options Nov 5 2011, 7:42 pm
Newsgroups: comp.lang.scheme
From: Pascal Costanza <p...@p-cos.net>
Date: Sun, 06 Nov 2011 00:42:29 +0100
Local: Sat, Nov 5 2011 7:42 pm
Subject: Re: identity
On 05/11/2011 22:45, time wrote:

> What is the rational for returning the identity for expressions such as (*) and (+)?

...to ensure the operators work well with apply.

Pascal

--
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
The views expressed are my own, and not those of my employer.


 
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.
John Cowan  
View profile  
 More options Nov 5 2011, 7:52 pm
Newsgroups: comp.lang.scheme
From: John Cowan <johnwco...@gmail.com>
Date: Sat, 5 Nov 2011 16:52:43 -0700 (PDT)
Local: Sat, Nov 5 2011 7:52 pm
Subject: Re: identity
On Nov 5, 5:45 pm, time <timreve...@gmail.com> wrote:

> What is the rationale for returning the identity for expressions such as (*) and (+)?

Well, if you interpret (apply + some-list) and (apply * some-other-
list) as left-folds, then a starting point is needed, something to
begin accumulating from.  The identity is the only value that works
correctly, so it's what gets returned when the list being folded over
has length 0.  Nobody would write (+) or (*) explicitly, but having
them return the identity is the Right Thing nevertheless.

The same argument applies when expanding macros: in a degenerate case,
a macro may expand to (+) or (*), and it's usually not appropriate to
raise an exception.


 
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.
Barry Margolin  
View profile  
 More options Nov 6 2011, 1:07 am
Newsgroups: comp.lang.scheme
From: Barry Margolin <bar...@alum.mit.edu>
Date: Sun, 06 Nov 2011 01:07:49 -0400
Local: Sun, Nov 6 2011 1:07 am
Subject: Re: identity
In article
<1050b059-5ae2-4224-af2d-a791fbf81...@n18g2000vbv.googlegroups.com>,
 John Cowan <johnwco...@gmail.com> wrote:

> On Nov 5, 5:45 pm, time <timreve...@gmail.com> wrote:

> > What is the rationale for returning the identity for expressions such as
> > (*) and (+)?

> Well, if you interpret (apply + some-list) and (apply * some-other-
> list) as left-folds, then a starting point is needed, something to
> begin accumulating from.  The identity is the only value that works
> correctly, so it's what gets returned when the list being folded over
> has length 0.  Nobody would write (+) or (*) explicitly, but having
> them return the identity is the Right Thing nevertheless.

> The same argument applies when expanding macros: in a degenerate case,
> a macro may expand to (+) or (*), and it's usually not appropriate to
> raise an exception.

Another way to explain it is that it allows the associative property to
include the limiting case of an empty argument list:

(+ a b c d e f) is obviously equivalent to any of the following:

(+ (+ a b c d e) (+ f))
(+ (+ a b c d) (+ e f))
(+ (+ a b c) (+ d e f))
...
(+ (+ a) (+ b c d e f))

When you define the empty cases as returning the identity, it also
includes:

(+ (+) (+ a b c d e f))

This then makes the right thing happen for apply.

--
Barry Margolin, bar...@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


 
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.
time  
View profile  
 More options Nov 15 2011, 4:28 pm
Newsgroups: comp.lang.scheme
From: time <timreve...@gmail.com>
Date: Tue, 15 Nov 2011 13:28:24 -0800 (PST)
Local: Tues, Nov 15 2011 4:28 pm
Subject: Re: identity
Hey, thanks!  At this point I'm assuming that this sort of thing can be discussed in terms of Lambda calculus ... I've just started Church's book -- which is more readable than some of his commentators! And Church seems to hook up nicely with thinking about logic and linguistics.  All of which what makes Scheme such an interesting language!

 
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 »