% is not an operator [was Re: Verbose and flexible args and kwargs syntax]

Jussi Piitulainen jpiitula at ling.helsinki.fi
Thu Dec 15 07:48:06 EST 2011


rusi writes:

> On Dec 15, 3:58 pm, Chris Angelico wrote:
> > On Thu, Dec 15, 2011 at 9:47 PM, Robert Kern wrote:
> > >  42 = 2 mod 5
> > >  2 = 42 mod 5
> >
> > It might make more sense to programmers if you think of it as
> > written:
> >
> > 42 = 2, mod 5
> > 2 = 42, mod 5
> >
> > ChrisA
> 
> For the record I should say that the guy who taught me abstract
> algebra, said about as much:
> He said that the notation
> a == b mod n
> should be written as
> a ==n b
> (read the == as 3 horizontal lines and the n as a subscript)

I think the modulus is usually given in parentheses and preferably
some whitespace: in text, a == b (mod n), using == for the triple -,
and in a display:

    a == b    (mod n).

I think even a == b == c (mod n), without repeating the modulus every
time. (A subscript sounds good if the modulus is simple. Perhaps it
often is.)

That way it does not even look like a binary operator. I think Graham,
Knuth, and Patashnik play it nicely in their book Concrete
Mathematics, where they have both mods: the congruence relation, and
the binary operator. The book is targeted for computer scientists.

As if mathematicians didn't use the exact same notations for different
purposes, even in the same context, and often with no problems
whatsoever as long as all parties happen to know what they are talking
about. Often the uses are analogous, but at least the two main uses of
(x,y) differ wildly. (So Knuth uses (x .. y) for the interval, but he
is a programmer.)



More information about the Python-list mailing list