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
zerop
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
 
Software Scavenger  
View profile  
 More options Oct 23 2001, 7:12 pm
Newsgroups: comp.lang.lisp
From: cubicle...@mailandnews.com (Software Scavenger)
Date: 23 Oct 2001 16:12:30 -0700
Local: Tues, Oct 23 2001 7:12 pm
Subject: zerop
What is the advantage of (zerop x) over (= 0 x)?  I.e. why does zerop
exist?  And if there is some good reason for having such a function,
why is it not named 0= to be in style with 1+ and 1-?

 
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.
Kent M Pitman  
View profile  
 More options Oct 23 2001, 7:45 pm
Newsgroups: comp.lang.lisp
From: Kent M Pitman <pit...@world.std.com>
Date: Tue, 23 Oct 2001 23:43:44 GMT
Local: Tues, Oct 23 2001 7:43 pm
Subject: Re: zerop

cubicle...@mailandnews.com (Software Scavenger) writes:
> What is the advantage of (zerop x) over (= 0 x)?  I.e. why does zerop
> exist?  And if there is some good reason for having such a function,
> why is it not named 0= to be in style with 1+ and 1-?

The function and its name are historical and occur in a lot of Lisp texts
going back a long way.  There's little reason to perturb it.

ZEROP is useful because it can be mapped and used as a one-place predicate
in various :test situations.  Ditto with PLUSP and MINUSP which you didn't
ask about.

IMO, 1+ and 1- are not terrific models of naming to be emulated, btw.
(1- x) confuses a lot of people.  My recollection is that we called it
-1+ in Yale Scheme, which I liked better.  It might get us into questions
of whether it was 0= or =0, too.  I personally find it abhorrent to see
(= 0 x); I prefer (= x 0).  I always put the constant term I'm searching
for second and the term I'm thumbing through first.  The math may be
symmetric, but the conversational English is not; to me "if 0 is x then..."
sounds like you're waiting for 0 to change its value to become like x.
(This is partly because in English, "x is red" can also asymmetrically
put a predicate in the second position, but not the first.)  Useless
quibbles like this are good reasons to just not muck with a perfectly
serviceable status quo.  

I also think Scheme's name zero? is quite aesthetic, btw, but in CL we
spell "?" as "p" out of tradition, and it might as well be more or
less uniformly done thus.


 
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.
David McClain  
View profile  
 More options Oct 23 2001, 8:44 pm
Newsgroups: comp.lang.lisp
From: "David McClain" <bar...@qwest.net>
Date: Tue, 23 Oct 2001 17:47:02 -0700
Local: Tues, Oct 23 2001 8:47 pm
Subject: Re: zerop

> of whether it was 0= or =0, too.  I personally find it abhorrent to see
> (= 0 x); I prefer (= x 0).  I always put the constant term I'm searching
> for second and the term I'm thumbing through first.  The math may be
> symmetric, but the conversational English is not; to me "if 0 is x
then..."
> sounds like you're waiting for 0 to change its value to become like x.

This is another learned defensive tactic that arises from writing C code...
It is too easy to write x = 0 when one really meant to write x == 0. So
instead, switching the order to 0 == x makes the first mistake wholly
unacceptable to the compiler and you don't get burned trying to track down
that nasty little bug....

- DM


 
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.
Erik Naggum  
View profile  
 More options Oct 23 2001, 10:20 pm
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.net>
Date: Wed, 24 Oct 2001 02:20:15 GMT
Local: Tues, Oct 23 2001 10:20 pm
Subject: Re: zerop
* Kent M Pitman
| I personally find it abhorrent to see (= 0 x); I prefer (= x 0).

  Since I frequently write (<= 0 foo <limit>), and read this as a test
  whether the arguments are increasing non-monotonically, instead of the
  more informal "less than or equal", which works only for two arguments in
  my view, just like (+ a b c) as which I read "sum of" rather than "plus",
  I find it more convenient to start the argument list with the constant.

  Also, in (< 4 x), the symbol < has the visual appeal that the arguments
  should have increasing values from left to right for the expression to be
  true, and likewise for > for decreasing values.  Using infix syntax, I
  would write x > 4, but I would also read it backwards.

///
--
  Norway is now run by a priest from the fundamentalist Christian People's
  Party, the fifth largest party representing one eighth of the electorate.
--
  The purpose of computing is insight, not numbers.   -- Richard Hamming


 
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.
Thomas F. Burdick  
View profile  
 More options Oct 23 2001, 10:41 pm
Newsgroups: comp.lang.lisp
From: t...@famine.OCF.Berkeley.EDU (Thomas F. Burdick)
Date: 23 Oct 2001 19:41:29 -0700
Local: Tues, Oct 23 2001 10:41 pm
Subject: Re: zerop

Erik Naggum <e...@naggum.net> writes:
> * Kent M Pitman
> | I personally find it abhorrent to see (= 0 x); I prefer (= x 0).

>   Since I frequently write (<= 0 foo <limit>), and read this as a test
>   whether the arguments are increasing non-monotonically, instead of the
>   more informal "less than or equal", which works only for two arguments in
>   my view, just like (+ a b c) as which I read "sum of" rather than "plus",
>   I find it more convenient to start the argument list with the constant.

>   Also, in (< 4 x), the symbol < has the visual appeal that the arguments
>   should have increasing values from left to right for the expression to be
>   true, and likewise for > for decreasing values.  Using infix syntax, I
>   would write x > 4, but I would also read it backwards.

I'm likely to write (= x 0), but I'd probably write

         (if (= 0 (foo x y (baz (car z)
                                (cdr z))))
             ...)

rather than

         (if (= (foo x y (baz (car z)
                              (cdr z)))
                0)
             ...)

which I find significantly less readable

--
           /|_     .-----------------------.                        
         ,'  .\  / | No to Imperialist war |                        
     ,--'    _,'   | Wage class war!       |                        
    /       /      `-----------------------'                        
   (   -.  |                              
   |     ) |                              
  (`-.  '--.)                              
   `. )----'                              


 
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 »