MaxBy -- a maximum element of a list |
Syntax |
MaxBy(L: LIST, LessThanFunc: FUNCTION) |
Description |
Example |
/**/ Define ByLength(S, T) -- define the sorting function /**/ Return len(S) < len(T); /**/ EndDefine; /**/ L := ["bird", "mouse", "cat", "elephant"]; /**/ MaxBy(L, ByLength); elephant /**/ use QQ[x,y]; /**/ Define ByLPP(S, T) return LPP(S) < LPP(T); EndDefine; /**/ L := [x^2*y -y -3, x^5 -1, x^5 -y^2 +3]; /**/ MaxBy(L, ByLPP); x^5 -1 |
See Also |