function that counts...

Grant Edwards invalid at invalid.invalid
Thu May 20 15:53:42 EDT 2010


On 2010-05-20, superpollo <utente at esempio.net> wrote:
> Grant Edwards ha scritto:
>> On 2010-05-20, superpollo <utente at esempio.net> wrote:
>>> Steven D'Aprano ha scritto:
>>>> On Wed, 19 May 2010 21:58:04 +0200, superpollo wrote:
>>>>
>>>>> ... how many positive integers less than n have digits that sum up to m:
>>>>
>>>> Does the name "prttn" mean anything? I'm afraid I keep reading it as
>>>> a mispelling of "print n".
>>>
>>> pArtItIOn
>> 
>> One might be tempted to suggest the name "partition".
>
> no kidding: i was afraid to use some reserved word...

Since Python is interactive, and you don't get charged for each time
you run your deck through the reader, that's easy enough to check:

   $ python
   Python 2.6.4 (r264:75706, Mar  1 2010, 10:33:43) 
   [GCC 4.1.2 (Gentoo 4.1.2 p1.1)] on linux2
   Type "help", "copyright", "credits" or "license" for more information.
   
   >>> partition
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
   NameError: name 'partition' is not defined
   
   >>> sum
   <built-in function sum>
   
   >>> int
   <type 'int'>
   
   >>> file
   <type 'file'>


Lest my allusions to Fortran IV be lost upon the less grizzled, only
the first 6 characters were significant in Fortran IV identifiers, and
removing all of the vowels from a longer word was an idiomatic way to
create an identifier with a length <= 6.

IIRC, the number 6 was originally chosen because that's how many 6-bit
characters you could hold in a single 36-bit CPU register.  That way
when writing a compiler/link/assembly you could compare two
identifiers using a single "CMP" instruction.

I'm not sure why 36-bits was such a popular ALU width, but many
different vendors sold 36-bit machines back in the day.

-- 
Grant Edwards               grant.b.edwards        Yow! Hand me a pair of
                                  at               leather pants and a CASIO
                              gmail.com            keyboard -- I'm living
                                                   for today!



More information about the Python-list mailing list