How to apply a function (like the sum) among all elements of a list?
In magma you have the possibility of invoking
&+[x0, x1, x2]
and that will return the sum of the elements in the array. You can also replace the sum operator by another binary operator that is associative. I'm wondering if SageMath has a similar feature, I've been looking in the documentation and apparently the best option is to use the built-in function sum()
, but this doesn't generalize to any other binary operation.
Thanks for the help!
Hey descudero, I'm having the "inverse" problem. How do you replace the sum for a associative binary operator in MAGMA? My question in fact is "how do you create an operator with MAGMA"? Thanks!