tuple to string?
steve at REMOVETHIScyber.com.au
Sun Jul 24 19:45:23 CEST 2005
On Sun, 24 Jul 2005 21:55:19 +1000, John Machin wrote:
>>>Look up the precedence rules? Are you aware of any language where * /
>>>and % _don't_ have the same precedence??
>> Do languages like Pascal that don't have string formatting expressions, or
>> use the % operator, count?
> A thousand pardons; I should have said "Are you aware of any language
> which has % (as primarily a numeric remainder/modulo operator) but * /
> and % _don't_ have the same precedence??"
Ah, I had completely forgotten that Pascal has a MOD operator that is
equivalent to % and has the same precedence as * / and DIV. So scratch
Pascal off the list.
But APL uses right-to-left precedence for all operators, and Forth uses
left-to-right. There may be others.
> OK, given a language which does have * and / used among other things for
> numerical multiply and divide, (a) are you aware of any such language
> which does does not have * and / at the same precedence level (b)
> supposing one wanted to introduce % as a numerical
> remainder/modulo/whatever operator (plus other meaning(s) for
> non-numeric types), would you care to argue that it should not have the
> same precedence level (as * and /)?
Yes I would.
Since the remainder (or modulo) operator is not distributive, the only
unambiguous usage is to use parentheses, or to decide on precedence rules.
The usual mathematical convention is that modulus has lower precedence
than addition, eg in "clock arithmetic" we expect that three hours after
ten is one: 10+3 modulo 12 is 1, not 13.
More information about the Python-list