On Apr 23, 2007, at 1:57 AM, proctor wrote:
> On Apr 22, 5:51 pm, Michael Bentley <[EMAIL PROTECTED]> wrote:
>> Oops! Note to self: *ALWAYS* try code before posting to a public
>> forum :-(
>>
>> def binary(val, width):
>> print '%10s = the sum of' % val
>> for i in [2 ** x for x
On Apr 22, 5:51 pm, Michael Bentley <[EMAIL PROTECTED]> wrote:
> Oops! Note to self: *ALWAYS* try code before posting to a public
> forum :-(
>
> def binary(val, width):
> print '%10s = the sum of' % val
> for i in [2 ** x for x in range(width - 1, -1, -1)]:
> a = v
On Apr 22, 8:23 pm, [EMAIL PROTECTED] (Alex Martelli) wrote:
> Steven Bethard <[EMAIL PROTECTED]> wrote:
>
>...
>
>
>
> > > import sys
> > > def ch4(item, n=0):
> > >if n < len(item):
> > >if item[n] == '0':
> > >item[n] = '1'
> > >
On Apr 22, 9:28 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> On 22 Apr 2007 19:13:31 -0700, proctor <[EMAIL PROTECTED]> declaimed the
> following in comp.lang.python:
>
>
>
> > :-)
>
> > this is good stuff. for learning especially! thank you again!
>
> Took me some time to find... M
On Apr 22, 9:13�pm, proctor <[EMAIL PROTECTED]> wrote:
> On Apr 22, 7:10 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > On 22 Apr 2007 17:06:18 -0700, proctor <[EMAIL PROTECTED]> declaimed the
> > following in comp.lang.python:
>
> > > > � � else:
> > > > � � � � # only one of carry
Alex Martelli wrote:
> Steven Bethard <[EMAIL PROTECTED]> wrote:
>...
>>> import sys
>>> def ch4(item, n=0):
>>>if n < len(item):
>>>if item[n] == '0':
>>>item[n] = '1'
>>>print ''.join(item)
>>>
Steven Bethard <[EMAIL PROTECTED]> wrote:
...
> > import sys
> > def ch4(item, n=0):
> >if n < len(item):
> >if item[n] == '0':
> >item[n] = '1'
> >print ''.join(item)
> >ch4(item)
> >
On Apr 22, 7:34 pm, Steven Bethard <[EMAIL PROTECTED]> wrote:
> proctor wrote:
> > On Apr 22, 2:06 pm, Steven Bethard <[EMAIL PROTECTED]> wrote:
> >> proctor wrote:
> >>> On Apr 22, 1:24 pm, Michael Bentley <[EMAIL PROTECTED]> wrote:
> On Apr 22, 2007, at 1:49 PM, proctor wrote:
> > i have
On Apr 22, 7:10 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> On 22 Apr 2007 17:06:18 -0700, proctor <[EMAIL PROTECTED]> declaimed the
> following in comp.lang.python:
>
> > > else:
> > > # only one of carry in, b1, or b2 is set
>
> #or none is set! Missed t
proctor wrote:
> On Apr 22, 2:06 pm, Steven Bethard <[EMAIL PROTECTED]> wrote:
>> proctor wrote:
>>> On Apr 22, 1:24 pm, Michael Bentley <[EMAIL PROTECTED]> wrote:
On Apr 22, 2007, at 1:49 PM, proctor wrote:
> i have a small function which mimics binary counting. it runs fine as
> lon
On Apr 22, 5:51 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> On Sun, 22 Apr 2007 17:37:05 -0500, Michael Bentley
> <[EMAIL PROTECTED]> declaimed the following in comp.lang.python:
>
> > Anything that can be done with recursion can be done without
> > recursion. If you really wanted to mimic
On Apr 22, 5:51 pm, Michael Bentley <[EMAIL PROTECTED]> wrote:
> Oops! Note to self: *ALWAYS* try code before posting to a public
> forum :-(
>
> def binary(val, width):
> print '%10s = the sum of' % val
> for i in [2 ** x for x in range(width - 1, -1, -1)]:
> a = v
Oops! Note to self: *ALWAYS* try code before posting to a public
forum :-(
def binary(val, width):
print '%10s = the sum of' % val
for i in [2 ** x for x in range(width - 1, -1, -1)]:
a = val / i
print ' ' * 13 + '%s * (2 ** %s)' % (a, width)
On Apr 22, 2007, at 5:47 PM, proctor wrote:
> On Apr 22, 4:37 pm, Michael Bentley <[EMAIL PROTECTED]> wrote:
>> On Apr 22, 2007, at 4:08 PM, proctor wrote:
>>
>>
>>
>>> On Apr 22, 2:55 pm, [EMAIL PROTECTED] wrote:
On Apr 22, 11:49 am, proctor <[EMAIL PROTECTED]> wrote:
>>
> hello,
>>
>>>
On Apr 22, 5:05 pm, tac-tics <[EMAIL PROTECTED]> wrote:
> Yes, you should use a for loop in this situation.
>
> Certain functional languages, such as Scheme and various LISP dialects
> allow for what is called "tail recursion" which effectively eliminates
> this problem by internally converting rec
Yes, you should use a for loop in this situation.
Certain functional languages, such as Scheme and various LISP dialects
allow for what is called "tail recursion" which effectively eliminates
this problem by internally converting recursion to iteration. Python
isn't really cut out for heavy recurs
On Apr 22, 4:37 pm, Michael Bentley <[EMAIL PROTECTED]> wrote:
> On Apr 22, 2007, at 4:08 PM, proctor wrote:
>
>
>
> > On Apr 22, 2:55 pm, [EMAIL PROTECTED] wrote:
> >> On Apr 22, 11:49 am, proctor <[EMAIL PROTECTED]> wrote:
>
> >>> hello,
>
> >>> i have a small function which mimics binary countin
On Apr 22, 2007, at 4:08 PM, proctor wrote:
> On Apr 22, 2:55 pm, [EMAIL PROTECTED] wrote:
>> On Apr 22, 11:49 am, proctor <[EMAIL PROTECTED]> wrote:
>>
>>
>>
>>> hello,
>>
>>> i have a small function which mimics binary counting. it runs
>>> fine as
>>> long as the input is not too long, but
On Apr 22, 2:06 pm, Steven Bethard <[EMAIL PROTECTED]> wrote:
> proctor wrote:
> > On Apr 22, 1:24 pm, Michael Bentley <[EMAIL PROTECTED]> wrote:
> >> On Apr 22, 2007, at 1:49 PM, proctor wrote:
>
> >>> i have a small function which mimics binary counting. it runs fine as
> >>> long as the input i
On Apr 22, 2:55 pm, [EMAIL PROTECTED] wrote:
> On Apr 22, 11:49 am, proctor <[EMAIL PROTECTED]> wrote:
>
>
>
> > hello,
>
> > i have a small function which mimics binary counting. it runs fine as
> > long as the input is not too long, but if i give it input longer than
> > 8 characters it gives
>
On Apr 22, 11:49 am, proctor <[EMAIL PROTECTED]> wrote:
> hello,
>
> i have a small function which mimics binary counting. it runs fine as
> long as the input is not too long, but if i give it input longer than
> 8 characters it gives
>
> RuntimeError: maximum recursion depth exceeded in cmp
>
> i
proctor wrote:
> On Apr 22, 1:24 pm, Michael Bentley <[EMAIL PROTECTED]> wrote:
>> On Apr 22, 2007, at 1:49 PM, proctor wrote:
>>
>>
>>
>>> i have a small function which mimics binary counting. it runs fine as
>>> long as the input is not too long, but if i give it input longer than
>>> 8 characte
On Apr 22, 1:24 pm, Michael Bentley <[EMAIL PROTECTED]> wrote:
> On Apr 22, 2007, at 1:49 PM, proctor wrote:
>
>
>
> > i have a small function which mimics binary counting. it runs fine as
> > long as the input is not too long, but if i give it input longer than
> > 8 characters it gives
>
> > Run
On Apr 22, 2007, at 1:49 PM, proctor wrote:
> i have a small function which mimics binary counting. it runs fine as
> long as the input is not too long, but if i give it input longer than
> 8 characters it gives
>
> RuntimeError: maximum recursion depth exceeded in cmp
>
> i'm not too sure what
24 matches
Mail list logo