PEP 303: Extend divmod() for Multiple Divisors

Erik Max Francis max at alcyone.com
Wed Jan 1 05:34:55 CET 2003


Thomas Bellman wrote:

> Abstract
> 
>     This PEP describes an extension to the built-in divmod() function,
>     allowing it to take multiple divisors, chaining several calls to
>     divmod() into one.

Provided backward compatibility is strictly maintained, sounds fine with
me.

	...

> Rationale
> 
>     The idea comes from APL, which has an operator that does this.  (I
>     don't remember what the operator looks like, and it would probably
>     be impossible to render in ASCII anyway.)

Oh boy oh boy!  I actually know this one.  It's an operator called
encode, which looks like a stylized T (you know, in the same way that
the "for every" symbol looks like a stylized inverted A).  (The decode
operator, which does the reverse operation, looks like an inverted T.) 
I don't know what the equivalent operator is in J, but no doubt there is
one.

>     The APL operator takes a list as its second operand, ...

Actually, the APL operator takes the list of moduli as the left
argument.

I knew that reading that APL book (a language I am almost certain never
to use in the real world in my entire life) last month would pay off! 
Now I'll be rich and famous!

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ All your slick moves / They were once innocent moves
\__/ Sade
    Bosskey.net: Quake III Arena / http://www.bosskey.net/q3a/
 A personal guide to Quake III Arena.




More information about the Python-list mailing list