Select 最大值中偶数索引处的元素
Select the elements at even indexes in maxima
在 maxima 中,"sublist" 允许您 select 具有不同标准的列表的某些元素。我想要 select 偶数索引处的元素。我想过
sublist([1,2,4,5,7,8],evenp(sublist_indices()));
但显然不行。不写for循环怎么办?
好吧,像这样的东西怎么样:
(%i2) L : [a, b, c, d, e, f, g];
(%o2) [a, b, c, d, e, f, g]
(%i3) makelist (L[2*i], i, 1, floor (length(L) / 2));
(%o3) [b, d, f]
在 maxima 中,"sublist" 允许您 select 具有不同标准的列表的某些元素。我想要 select 偶数索引处的元素。我想过
sublist([1,2,4,5,7,8],evenp(sublist_indices()));
但显然不行。不写for循环怎么办?
好吧,像这样的东西怎么样:
(%i2) L : [a, b, c, d, e, f, g];
(%o2) [a, b, c, d, e, f, g]
(%i3) makelist (L[2*i], i, 1, floor (length(L) / 2));
(%o3) [b, d, f]