math icon indicating copy to clipboard operation
math copied to clipboard

factorize should be more limited

Open sorawee opened this issue 5 years ago • 3 comments

It would be ideal if factorize is injective. It is not right now due to how (factorize 0) = (factorize 1) = '(). Changing the type of the domain to Positive-Integer is one possibility to accomplish this.

sorawee avatar Dec 29 '19 09:12 sorawee

Also, regardless of this, the type of the co-domain could be strengthen to (Listof (List Positive-Integer Positive-Integer)).

sorawee avatar Dec 29 '19 09:12 sorawee

Wait. Isn't (factorize 0) = '() simply an mistake?

The empty product is 1, so an empty list of factors represents 1.

soegaard avatar Jan 23 '22 17:01 soegaard

I agree, (factorize 0) should raise an error or return ((0 1)) or something else but definitely not return '(). The easiest fix is definitely to change the domain to Positive-Integer.

pavpanchekha avatar Jan 24 '22 03:01 pavpanchekha