> 数学 >
能解释下这个mathematica定义的函数么?
partition[l_,v_,comp_]:=Flatten/@Reap[
Scan[
Which[com[#,v],Sow[#,-1],
comp[v,#],Sow[#,1],True,Sow[#,0]&,l],{-1,0,1}][[2]]
用法:
partition[{3,5,7,9,2,4,6,8,3,4},4,Less]
Sow[#,1]和Reap的第二个参数{-1,0,1}没看明白,
人气:216 ℃ 时间:2020-05-08 18:33:05
解答
这有个现成的.
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版