gcd, contrary to lcm that work both on list and simple arguments, does not work on lists.
(%i1) A:[10,6];
(A) [10,6]
(%i2) gcd(A);
(wxMaxima is configured not to show long expressions - which would be slow)
-- an error. To debug this try: debugmode(true);
But
(%i3) gcd(10,6);
(%o3) 2
is ok.
I expected to work just as lcm do
(%i5) lcm(10,6);lcm([10,6]);
(%o4) 30
(%o5) 30
I count not find any way, by apply or map lamda etc, to convert list to arguments so as to make gcd to work on lists.
Here is one way to find the
gcd
of the members of a list:In the user documentation for
gcd
andlcm
, I don't see any mention of calling either function on a list. So I'd say that this bug report of is more of a feature request to (i) expand the user documentation forlcm
and (ii) allowgcd
to be called on a list.Yes indeed. in that sense looks like a feature request. Also thank you for the single quote. Because of the working apply(min,[10,6]) I did not think to add the quote before gcd.
Heh. I was surprised to see that
gcd
needed single quote. If you leave it off, you get something likespmod(10,6)
. Then I remembered thatgcd
also names a variable whose default value isspmod
.I think the documentation could be improved so that the functions
gcd
and the variablegcd
had different entries. Now you have to get to the second paragraph after a long first paragraph to find out abou the variable.There's nothing in the doc suggesting that
gcd([4,6,8])
will work. I'm surprised thatlcm
allows it.It's good practice to always quote a function to avoid surprises.
I'm surprised that Barton didn't mention the nicer way (which he introduced) of making a 2-argument function into an n-argument one,
xreduce
(alsorreduce
andlreduce
if you want to control how it associates).Closing as not a bug.