sequence multiplied by -1

Arnaud Delobelle arnodel at gmail.com
Sun Sep 26 14:51:02 EDT 2010


Paul Rubin <no.email at nospam.invalid> writes:

> Seebs <usenet-nospam at seebs.net> writes:
>> * It seems clear that, given two sequences x and y, "x + y" ought to
>>   be the concatenation of these sequences.
>>...
>> Helps, perhaps, that I got exposed to group theory early enough to be used
>> to redefining + and * to be any two operations which have interesting
>> properties*.
>
> But groups have only one of those operators, and when it's written as +
> that usually means the group is commutative.  So you wouldn't want + to
> denote sequence concatenation.  If + and * are both present, that sounds
> like a ring, in which case you'd want "foo"*"bar" to work.  It actually
> seems to me that exponentiation makes more sense than multiplication
> for turning "a" into "aaa".  We think of aaa as what results from
> writing "a" with "3" in the superscript position

This is common notation in Computer Science.  Word concatenation is
often denoted multiplicatively (with the sign generally omitted) and so
it follows naturally that exponentiation is used for repeated
concatenation of a word with itself.

This is also in keeping with group (or rather in in this case, monoid)
theory notation where commutative group / monoid composition laws are
denoted additively and non-commutative ones multiplicatively.

So it would probably have been more in keeping with established
mathematical / theoretical CS notation to write:

     "spam" * "eggs" instead of "spam" + "eggs"

and

     "spam"**3 instead of "spam"*3

However it wouldn't prevent people from thinking about giving a meaning
to e.g.

    "spam"**-2

-- 
Arnaud



More information about the Python-list mailing list