Re: Range function

2005-05-15 Thread David Formosa (aka ? the Platypus)
On 15 May 2005 02:50:38 -0700, Xah Lee <[EMAIL PROTECTED]> wrote: > Here's the Perl code. Where did you learn to program? Its highly unlikely that a Perl programer would ever write a range function as there is a built in Perl function that does the same thing. If your intent is purely accedemic

Re: Range function

2005-05-15 Thread Peter Hansen
Xah Lee wrote: > the previous posted solutions are badly botched. > def Range(iMin, iMax=None, iStep=None): [snip hideous code] > # Thanks to Peter Hansen for a correction. Ohmigod, he's only made it worse and he's blaming me for it. Shows what I get for replying to a cross-posted troll messag

Re: Range function

2005-05-15 Thread Xah Lee
the previous posted solutions are badly botched. Here's a better solution. Any further correction will appear on the website instead. (http://xahlee.org/tree/tree.html) Similar change needs to be made for the Perl code... Java code will come tomorror. By the way, the code from me are not expecte

Re: Range function

2005-05-15 Thread Peter Hansen
Xah Lee wrote: > Here's the Python solution. > # implementation note: When iStep is a decimal, rounding error > # accumulates. For example, the last item returned from > # Range(0,18,0.3) is 17.7 not 18. A remedy is to turn iStep into a > # fraction and do exact arithmetics, and possibly convert th

Re: Range function

2005-05-15 Thread Xah Lee
Here's the Python solution. -- # -*- coding: utf-8 -*- # Python # http://xahlee.org/tree/tree.html # Xah Lee, 2005-05 # implementation note: When iStep is a decimal, rounding error # accumulates. For example, the last item returned from # Range(0,18,0.3) is 17.7 not 18. A remedy is to tu

Re: Range function

2005-05-15 Thread Xah Lee
Here's the Perl code. -- #! perl # http://xahlee.org/tree/tree.html # Xah Lee, 2005-05 #_ Range _ _ _ _ =pod B Range($iMax) generates the list [1, 2, ... , $iMax]. Range($iMin, $iMax) generates the list [$iMin, ... , $iMax]. Range($iMin, $iMax, $iStep) uses incr