Re: First use of Lisp at work!

From: Pascal Bourguignon (spam_at_mouse-potato.com)
Date: 11/10/04


Date: 10 Nov 2004 12:11:40 +0100

pkhuong@gmail.com (Paul Khuong) writes:
> Mmm. Interesting. How do they deal with the precedence of unary and
> binary minus? (Aaah, unary minus having lower precedence than
> exponentiation. The source of so many middle school errors :)
> Actually, how does your parser deal with them? I only took a quick
> look at the infix2lisp part, so i'm not sure how it copes with that
> problem.

I don't know who the various infix languages cope with it, but I know
how I do: add parenthesis!

                        ((-n)^2)-1
or: -((n^2)-1)

-- 
__Pascal Bourguignon__


Relevant Pages

  • Re: First use of Lisp at work!
    ... >> brain by excessive use of HP calculators in college, but I prefer RPN ... unary minus having lower precedence than ...
    (comp.lang.lisp)
  • Re: Problem with exponentiation: -2**2 gives 4 instead of -4
    ... programming languages, in that the developers got something wrong. ... confusion about the difference between the negation operator (unary ... minus) and the subtraction operator (binary minus). ... Otherwise, instead of complaining about the evils of unary minus, we ...
    (comp.lang.tcl)
  • Re: defining inverse number
    ... Binary minus is not fundamental ... because it can be represented via unary minus, which in turn is just a ... So subtraction is really adding the additive inverse. ...
    (sci.math)
  • Re: math.nroot [was Re: A brief question.]
    ... as 2 and the unary minus as an operator with lower precedence than exponentiation. ... a unary -, which binds lower than exponentiation in most systems, or part of the negative number minus 2. ... In Python, all numbers are positive. ...
    (comp.lang.python)
  • Re: defining inverse number
    ... real and complex number algebra). ... Binary minus is not fundamental ... because it can be represented via unary minus, which in turn is just a ... From -a to a required the use of an additional operator, viz. ...
    (sci.math)