iOn 3/8/07, Jonathan Bober <[EMAIL PROTECTED]> wrote:
> Hi all. The following (minor) issue has been bothering me a little bit
>  for a while.
>
>  Currently if I write lcm([1,2,3]), I get six, but lcm( (1,2,3) ) gives
>  an error. (And similarly for gcd.) This is because the lcm and gcd
>  functions (these are in rings/arith.py) contain code like the following:
>
>  if isinstance(a, list):
>      return __LCM_list(a)
>
>  I just changed all occurrences of the first of these lines in the lcm
>  and gcd functions in my own installation to read
>
>  if isinstance(a,list) or isinstance(a,tuple):
>
>  and now I can find the lcm or gcd of a tuple just fine.
>
>  Is there any reason I shouldn't do this? If not, I guess that this is a
>  bug report/fix.
(1) You should use
       if isinstance(a, (list, tuple)):
          ...

(2) Then you should send me a patch :-), since you want your change to
be in the next version of SAGE, right.   Thanks.

   sage: hg_sage.diff()
   sage: hg_sage.ci()
   sage: hg_sage.send('patchname')

(3)  (Also, I feel that, ideally, lcm/gcd ought to be able to
>  handle something like an xrange object, or, in general, any
>  iterator/generator. But that is another issue.)

If we added that, would you be fine with gcd/lcm going into an
infinite loop in some cases if the iterator is infinite?  Probably that is fine.
Yes, I think I'd be fine with adding what you suggest, i.e., lcm and
gcd also handling iterators.

Wiliam

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to