On Sun, Sep 20, 2009 at 11:49 AM, Tom Boothby <tomas.boot...@gmail.com> wrote:
>
> Maybe this is dumb -- but I'm perpetually bitten by it.  Often times,
> I want to factor a list of numbers.  Sometimes, a zero will pop up in
> the list, and I get an exception.
>
> Ok, so there isn't a unique prime factorization of zero.  But, there
> isn't a unique prime factorization of a negative integer, either, but
> we don't raise exceptions there.
>
> My preference would be that factor works for all integers.  It's not
> like it's hard to factor 0 or anything.  We just return the
> factorization object [(0,1)].

I think I would prfer the empty list of primes and a "unit" of 0:

sage: X = Factorization([],unit=0)
sage: X
0
sage: X*X
0
sage: list(X)
[]

William

>
> Thoughts?
>
> Of course this is easy to solve:
>
> {{{
>    for a,b,c in data:
>        print a,b, factor(c)
> }}}
>
> just has to be
>
> {{{
>    for a,b,c in data:
>        if c != 0:
>            print a, b, factor(c)
>        else:
>            print a,b, 0
> }}}
>
> but... the second is ugly and there's (IMHO) no reason for it.
>
>   --tom
>
> >
>



-- 
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to