• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Order of operations (was: Eigenvalues &/or eigenvectors,
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Order of operations (was: Eigenvalues &/or eigenvectors,


  • Subject: Re: Order of operations (was: Eigenvalues &/or eigenvectors,
  • From: Paul Berkowitz <email@hidden>
  • Date: Mon, 12 May 2003 13:25:37 -0700

On 5/12/03 12:28 PM, "Michael Sullivan" <email@hidden> wrote:

> With explicit numbers, I will concede that your interpretation is at
> least as reasonable as mine (which would be that -3^2 is to be read as:
> - (3)^2).
>
> But not with variables.
>
> If I write -x^2, I expect the result to be a *negative* number.
>
> But applescript doesn't:
>
> set foo to 3
> -foo ^ 2
>
> --> 9.0
>
> Sorry, but that's just wrong.

No it isn't. It makes perfect sense to me. Whether foo itself is a positive
or negative number, -foo is the opposite sign - negative or positive number
respectively , so squaring either foo or -foo yields a positive number, just
as for the signed integer represented by the variable x. Cubing it would
give it the same sign as the integer being cubed (foo or -foo).

This is _especially_ clear in the version you've pasted, where there are
spaces on either side of the ^ symbol, so that the - sign is clearly
attached to just the variable foo and not to the whole expression. It would
be totally perverse to expect

-foo ^ 2

to mean

-(foo^2)

I think that the fact that Applescript itself compiles

(foo^2)

as

(foo ^ 2)

whereas

-foo

compiles as is (here "-" is the unary negative operator, whereas ^ is always
a binary operator) makes AppleScript's view if the issue unambiguously
clear.

If you don't like AppleScript's method, just use parentheses and stop
complaining about it.

--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Order of operations (was: Eigenvalues &/or eigenvectors,
      • From: Gary Lists <email@hidden>
    • Re: Order of operations (was: Eigenvalues &/or eigenvectors,
      • From: email@hidden (Michael Sullivan)
References: 
 >Re: Order of operations (was: Eigenvalues &/or eigenvectors, (From: email@hidden (Michael Sullivan))

  • Prev by Date: Re: SE2beta contextual Find feature request
  • Next by Date: My operator can beat up your operator.
  • Previous by thread: Re: Order of operations (was: Eigenvalues &/or eigenvectors,
  • Next by thread: Re: Order of operations (was: Eigenvalues &/or eigenvectors,
  • Index(es):
    • Date
    • Thread