From: Ken Tilton
Subject: hey, what happened to this NG?
Date: 
Message-ID: <nrfqg.111$du3.77@fe08.lga>
You guys used to know everything. So far no one has told me:

(a) how to switch the ( and [ keys on ACL
(b) an iteration form for loop where the right side returns multiple 
values (shy of using multiple-values-list)

Here is another:

   How would you parse -4x?

    (a) (* (- 4) x)
    (b) (- (* 4 x))
    (c) other _________________

kenny

-- 
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon

From: numeromancer
Subject: Re: hey, what happened to this NG?
Date: 
Message-ID: <1151986511.713396.210330@b68g2000cwa.googlegroups.com>
Ken Tilton wrote:
> You guys used to know everything. So far no one has told me:
>
> (a) how to switch the ( and [ keys on ACL
> (b) an iteration form for loop where the right side returns multiple
> values (shy of using multiple-values-list)
>
> Here is another:
>
>    How would you parse -4x?
>
>     (a) (* (- 4) x)
>     (b) (- (* 4 x))
        (c) other :   (* -1 4 x)

One of the most common mistakes beginning algebra students make is to
say that
-4^2 = 16. This is due, I think, to language: we say `-4' is
`negative-four', so `-4^2' must be `negative-four, squared', but it
isn't; it is, of course,  `negative four-squared'.  (b) suggests `-4+x
=> (- (+ 4 x))', also wrong.  (c) might too, but it uses the same basic
operator, so it must be evaluated left-to-right.  Except for ^, which
is right-to-left.  I'll stick with prefix notation and WFFs.
(with-can-of-worms
    This is rarely covered in a principled way in modern algebra
textbooks.)

Tim S
>
> kenny
>
> --
> Cells: http://common-lisp.net/project/cells/
>
> "I'll say I'm losing my grip, and it feels terrific."
>     -- Smiling husband to scowling wife, New Yorker cartoon
From: Ken Tilton
Subject: Re: hey, what happened to this NG?
Date: 
Message-ID: <2nmqg.767$du3.596@fe08.lga>
numeromancer wrote:
> Ken Tilton wrote:
> 
>>You guys used to know everything. So far no one has told me:
>>
>>(a) how to switch the ( and [ keys on ACL
>>(b) an iteration form for loop where the right side returns multiple
>>values (shy of using multiple-values-list)
>>
>>Here is another:
>>
>>   How would you parse -4x?
>>
>>    (a) (* (- 4) x)
>>    (b) (- (* 4 x))
> 
>         (c) other :   (* -1 4 x)
> 
> One of the most common mistakes beginning algebra students make is to
> say that
> -4^2 = 16. This is due, I think, to language: we say `-4' is
> `negative-four', so `-4^2' must be `negative-four, squared', but it
> isn't; it is, of course,  `negative four-squared'.

"of course" meaning "by convention" only. To me it implies that there 
are no such things as negative numbers. If there are, how can any 
operator such as exponentiation prevail over the identity of -4 with its 
negative sign? It could not, so of course we must have two facts: minus 
four is the operator minus applied to the number four, and second, the 
precedence of exponentiation must exceed that of the minus sign "operator".

>  (b) suggests `-4+x
> => (- (+ 4 x))', also wrong.

Yikes, you just change from one operation to another (* to +) without 
considering order of operations?! Typical Lispnik.

k

-- 
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon
From: numeromancer
Subject: Re: hey, what happened to this NG?
Date: 
Message-ID: <1152151050.321585.306570@v61g2000cwv.googlegroups.com>
Ken Tilton wrote:
> numeromancer wrote:
> > Ken Tilton wrote:
> >
> >>You guys used to know everything. So far no one has told me:
> >>
> >>(a) how to switch the ( and [ keys on ACL
> >>(b) an iteration form for loop where the right side returns multiple
> >>values (shy of using multiple-values-list)
> >>
> >>Here is another:
> >>
> >>   How would you parse -4x?
> >>
> >>    (a) (* (- 4) x)
> >>    (b) (- (* 4 x))
> >
> >         (c) other :   (* -1 4 x)
> >
> > One of the most common mistakes beginning algebra students make is to
> > say that
> > -4^2 = 16. This is due, I think, to language: we say `-4' is
> > `negative-four', so `-4^2' must be `negative-four, squared', but it
> > isn't; it is, of course,  `negative four-squared'.
>
> "of course" meaning "by convention" only.

Here, of course "of course" means, by convention, "by convention".

> To me it implies that there
> are no such things as negative numbers.

I think it rather implies that we have no convention for representing
negative numbers. `-x' cannot mean what we usually call it,
``negative-x'' , but ``the result of the negation operation on x''.
I've seen some texts place the `-' as a subscript on the left hand side
of a number or variable, like what {}^{-}x might render in TeX with
some kerning adjustment.  Thus ``negative'' becomes an attribute of x
(thus syntactically, ``binds more tightly''), and not a shortcut for an
operation on x of penultimate precedence.

>If there are, how can any
> operator such as exponentiation prevail over the identity of -4 with its
> negative sign? It could not, so of course we must have two facts: minus
> four is the operator minus applied to the number four, and second, the
> precedence of exponentiation must exceed that of the minus sign "operator".

Exactly.

> >  (b) suggests `-4+x
> > => (- (+ 4 x))', also wrong.
>
> Yikes, you just change from one operation to another (* to +) without
> considering order of operations?! Typical Lispnik.

I was trying to think as a naive algebra student might think, but I'll
certainly take `Lispnik' as a complement;  thanks.

Tim S.
From: Alexander Schmolck
Subject: Re: hey, what happened to this NG?
Date: 
Message-ID: <yfswtauxsvj.fsf@oc.ex.ac.uk>
Ken Tilton <·········@gmail.com> writes:

>    How would you parse -4x?
> 
>     (a) (* (- 4) x)
>     (b) (- (* 4 x))
      (c) other (* -4 x)

'as
From: Ken Tilton
Subject: Re: hey, what happened to this NG?
Date: 
Message-ID: <jUgqg.32$0Y6.24@fe10.lga>
Alexander Schmolck wrote:
> Ken Tilton <·········@gmail.com> writes:
> 
> 
>>   How would you parse -4x?
>>
>>    (a) (* (- 4) x)
>>    (b) (- (* 4 x))
> 
>       (c) other (* -4 x)
> 
> 'as

Ah, but -3^2 => -9, so I am afraid -4 cannot exist. :)

Anyway, how about -xy? (~ (* x y)) or (* (~ x) y)

kt

-- 
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon
From: Alexander Schmolck
Subject: Re: hey, what happened to this NG?
Date: 
Message-ID: <yfsirmdy6j9.fsf@oc.ex.ac.uk>
Ken Tilton <·········@gmail.com> writes:

> Alexander Schmolck wrote:
> > Ken Tilton <·········@gmail.com> writes:
> >
> 
> >>   How would you parse -4x?
> >>
> >>    (a) (* (- 4) x)
> >>    (b) (- (* 4 x))
> > (c) other (* -4 x)
> 
> > 'as
> 
> 
> Ah, but -3^2 => -9, so I am afraid -4 cannot exist. :)

Well, in this case (and for rationals and complex numbers) you have to choose
between having non-crippled number-literals and conforming to standard math
notation. I guess for you this likely is a non-choice but if I were to do
infix prog lang design I'd at least consider parsing -3/4^4 as (expt -3/4 4),
(I'd presumably not use / for the division operator then, though). 

Still, for the multiplication case I can't see why you can't immediately
canonicalize from expression (a) to (c). I can't see the point of parsing as
(b).

> 
> Anyway, how about -xy? (~ (* x y)) or (* (~ x) y)

BTW using - for negation and ~ for subtraction is IMO a much better idea (I'm
not sure what possessed the SML folks, at least they had the sense to
differentiate between the 2, something all lisps seem to screw up. IIRC one of
the most obvious downsides of SML's choice is that it can't easily
interoperate with number literals from other languages (you have to jump
through hoops to print and parse them). Apart from that ~ is more
aesthetically pleasing -- it is asymmetric as is IMO desirable for a
non-commutative operation and it's less essential than negation, so the
simpler - symbol should go to negation).

'as
From: Marcin 'Qrczak' Kowalczyk
Subject: Re: hey, what happened to this NG?
Date: 
Message-ID: <87wtatbh5v.fsf@qrnik.zagroda>
Alexander Schmolck <··········@gmail.com> writes:

> Well, in this case (and for rationals and complex numbers) you have
> to choose between having non-crippled number-literals and conforming
> to standard math notation.

If a constant expression can appear anywhere a literal can (as is true
in most languages), having literals for only a subset of values is fine.

> BTW using - for negation and ~ for subtraction is IMO a much better idea

I prefer - for both.

-- 
   __("<         Marcin Kowalczyk
   \__/       ······@knm.org.pl
    ^^     http://qrnik.knm.org.pl/~qrczak/
From: Stefan Mandl
Subject: Re: hey, what happened to this NG?
Date: 
Message-ID: <4gth42F1p5m1oU1@news.dfncis.de>
>   How would you parse -4x?
> 
>    (a) (* (- 4) x)
>    (b) (- (* 4 x))
>    (c) other _________________
> 

(a) and (b) give the same value right?

I find (a) somehow clearer, as you could then use a rule like this:
"unary operators bind closer than binary, bind closer than ternary, bind 
closer than .."

regards,
Stefan

 > hey, what happened to this NG?

what do you mean? Little action the recent days?
From: Ken Tilton
Subject: Re: hey, what happened to this NG?
Date: 
Message-ID: <RVgqg.34$0Y6.29@fe10.lga>
Stefan Mandl wrote:
>>   How would you parse -4x?
>>
>>    (a) (* (- 4) x)
>>    (b) (- (* 4 x))
>>    (c) other _________________
>>
> 
> (a) and (b) give the same value right?
> 
> I find (a) somehow clearer, as you could then use a rule like this:
> "unary operators bind closer than binary, bind closer than ternary, bind 
> closer than .."
> 
> regards,
> Stefan
> 
>  > hey, what happened to this NG?
> 
> what do you mean?

No answers to (a) and/or (b).

> Little action the recent days?

Nah, it's summer, and it still seems to be true that only academia uses 
Lisp (and academia really knows how to take a summer off).

kenny


-- 
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon
From: Thomas F. Burdick
Subject: Re: hey, what happened to this NG?
Date: 
Message-ID: <xcv3bdh7m7p.fsf@conquest.OCF.Berkeley.EDU>
Ken Tilton <·········@gmail.com> writes:

> Stefan Mandl wrote:
>
> > Little action the recent days?
> 
> Nah, it's summer, and it still seems to be true that only academia
> uses Lisp (and academia really knows how to take a summer off).

I thought that ECLMs 2005 and 2006 showed pretty convincintly that
Europeans use Lisp in industry.  Also goes along with the summer off thing.
From: Stefan Scholl
Subject: Re: hey, what happened to this NG?
Date: 
Message-ID: <2T39fnjeIr0fNv8%stesch@parsec.no-spoon.de>
Ken Tilton <·········@gmail.com> wrote:
> Nah, it's summer, and it still seems to be true that only academia uses 
> Lisp (and academia really knows how to take a summer off).

Then use an academia free programming language like PHP. :-)
From: Barry Margolin
Subject: Re: hey, what happened to this NG?
Date: 
Message-ID: <barmar-135B15.21561103072006@comcast.dca.giganews.com>
In article <···············@news.dfncis.de>,
 Stefan Mandl <············@informatik.uni-erlangen.de> wrote:

> >   How would you parse -4x?
> > 
> >    (a) (* (- 4) x)
> >    (b) (- (* 4 x))
> >    (c) other _________________
> > 
> 
> (a) and (b) give the same value right?
> 
> I find (a) somehow clearer, as you could then use a rule like this:
> "unary operators bind closer than binary, bind closer than ternary, bind 
> closer than .."

(c) (* -4 x)

I.e. it depends on whether you consider the - to be a unary operator or 
part of the lexical syntax of a negative number.

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
From: Kent M Pitman
Subject: Re: hey, what happened to this NG?
Date: 
Message-ID: <u1wt24142.fsf@nhplace.com>
Stefan Mandl <············@informatik.uni-erlangen.de> writes:

> >   How would you parse -4x?
> >    (a) (* (- 4) x)
> >    (b) (- (* 4 x))
> >    (c) other _________________
> >
> 
> (a) and (b) give the same value right?

The resource use (whether you fall into bignums) and/or whether you
underflow/overflow floats might be different.  In general, the order
of contagion can have subtle effects like that.  I don't know if you
can prove that in this case it doesn't.

Also, if x is 0.0, (- 0.0) can give -0.0 but I believe (* -4 0.0) gives 0.0.
Though I didn't double-check IEEE.

> I find (a) somehow clearer, as you could then use a rule like this:
> "unary operators bind closer than binary, bind closer than ternary,
> bind closer than .."

I prefer the tighter binding of unary minus.  I have seen a lot of
parser tables in my time, and I think most of them say that when a
minus sign appears next to a number, people expect it to attach pretty
tightly.

The ambiguous case is where two unary operators, one prefix and one
postfix, are used.  e.g., -3! ... I particularly hate that one.
And -3!! is even worse, depending on whether you believe there is such
a thing as "skip" or "double" factorial.

One of the reasons I like to use Lisp is so that I don't have to carry
a parse precedence table in my pocket to help me figure things like
this out.  The parens tell the story.
From: Marcin 'Qrczak' Kowalczyk
Subject: Re: hey, what happened to this NG?
Date: 
Message-ID: <871wt1cvx5.fsf@qrnik.zagroda>
Kent M Pitman <······@nhplace.com> writes:

> Also, if x is 0.0, (- 0.0) can give -0.0 but I believe (* -4 0.0) gives 0.0.

(* -4 0.0) is -0.0.

I prefer to let unary minus has the same precedence as binary minus,
just like in mathematics.

-- 
   __("<         Marcin Kowalczyk
   \__/       ······@knm.org.pl
    ^^     http://qrnik.knm.org.pl/~qrczak/
From: Thomas F. Burdick
Subject: Re: hey, what happened to this NG?
Date: 
Message-ID: <xcv7j2t7mam.fsf@conquest.OCF.Berkeley.EDU>
Ken Tilton <·········@gmail.com> writes:

> You guys used to know everything. So far no one has told me:
> 
> (a) how to switch the ( and [ keys on ACL

I don't know the right way to do it, but you could try poking around
inside ide.base::*emacs-bindings*

> (b) an iteration form for loop where the right side returns multiple
> values (shy of using multiple-values-list)

Doesn't exist.  But if you're just trying to avoid the consing, the
other work-around is:

  (loop with a and b
        for i below 10
        do (setf (values a b) (floor i 3))
        ...)
From: Marco Baringer
Subject: Re: hey, what happened to this NG?
Date: 
Message-ID: <m2mzbp7lb0.fsf@bese.it>
Ken Tilton <·········@gmail.com> writes:

> You guys used to know everything. So far no one has told me:
>
> (a) how to switch the ( and [ keys on ACL

use emacs and eli :)

> (b) an iteration form for loop where the right side returns multiple
> values (shy of using multiple-values-list)

it's not possible with loop (afaik) but it is with iterate (as are a
bunch of other things):

(iterate
  (for (values a b c) = (foo))
  ....)

-- 
-Marco
Ring the bells that still can ring.
Forget your perfect offering.
There is a crack in everything.
That's how the light gets in.
	-Leonard Cohen
From: Kaz Kylheku
Subject: Re: hey, what happened to this NG?
Date: 
Message-ID: <1152057024.225272.232690@v61g2000cwv.googlegroups.com>
Ken Tilton wrote:
>    How would you parse -4x?
>
>     (a) (* (- 4) x)
>     (b) (- (* 4 x))
>     (c) other _________________

That depends on whether the language being parsed has a unary minus, or
whether a leading minus is part of the lexical syntax of a number.

If it's a unary minus, then (b) due to the higher precedence of
multiplication relative to unary minus. That abstract syntax tree node
better represents the original language, retaining the information that
a unary operator was applied.

If, on the other hand, the minus sign is part of the numeric constant
in that language, then the Lisp representation would be:

  (* -4 x)

Both cases could be required, for a suitably defined input language.
Suppose that - 4x is syntactically a the unary minus, but -4x means the
constant -4 times x. Then the former would be (- (* 4 x)) and the later
would be (* -4 x).

This way if, for instance, you wanted to pret^H^H^H^Hugly-print that
syntax node back to the original language, the information is there.