rtoy / maxima

A Clone of Maxima's repo
Other
0 stars 0 forks source link

gcd doesn't check type of arguments #2690

Open rtoy opened 1 week ago

rtoy commented 1 week ago

Imported from SourceForge on 2024-07-06 18:08:34 Created by macrakis on 2024-02-28 15:34:22 Original: https://sourceforge.net/p/maxima/bugs/4268


gcd([4,6],[4,6) returns [4,6] and gcd([4,6],[6,4]) returns 1. Both of these should be errors because gcd is not defined on lists.

If we want to define it as point-wise gcd (not especially useful), I suppose the results should be [1,1] and [2,2], but that isn't specified anywhere.

rtoy commented 1 week ago

Imported from SourceForge on 2024-07-06 18:08:35 Created by robert_dodier on 2024-03-04 21:20:32 Original: https://sourceforge.net/p/maxima/bugs/4268/#6655


I am inclined to say a list argument is an error instead of trying to give it a convenience interpretation. If someone wants to apply the function element by element, it's not a big deal to write map('gcd, [4, 6], [4, 6]).

rtoy commented 1 week ago

Imported from SourceForge on 2024-07-06 18:08:38 Created by rtoy on 2024-03-13 23:34:11 Original: https://sourceforge.net/p/maxima/bugs/4268/#8d86


Is the intent to throw an error if the (either) arg is a list? What about other things like gcd(a=b, c=d)? Or gcd(matrix([1]), matrix([2])). Presumably these are all errors.

What are the valid types for the args of gcd?

rtoy commented 1 week ago

Imported from SourceForge on 2024-07-06 18:08:42 Created by macrakis on 2024-03-14 01:05:11 Original: https://sourceforge.net/p/maxima/bugs/4268/#cd20


If the top level is in relational-ops or other-infix-ops or is a programming operator (mdo, mcond, mreturn, ...), it's an error. It would be nice if we could say that any verb is disallowed, but unfortunately undefined functions look like verbs -- op(sin(x)) is a noun, but op(f(x)) is a verb.