Find maximum value and index in a Maxima list?

大城市里の小女人 提交于 2019-12-08 05:30:31
Robert Dodier

lmax returns the maximum value of a list. Given x is a list, then

 lmax(x)

returns its minimum value.

Getting the index of the maximum value is a little more involved. The most relevant built-in function (unless I'm forgetting something -- could happen) is sublist_indices, which returns the indices of the elements which satisfy a predicate. The predicate is a function of one variable which returns true or false. To continue the example, `

sublist_indices(x, lambda([x1], x1 = lmax(x)))

returns one or more indices at which the elements of x take on the maximum value.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!