gpt4 book ai didi

select - Mathematica 中嵌套列表的条件选择

转载 作者:行者123 更新时间:2023-12-04 23:53:05 27 4
gpt4 key购买 nike

考虑:

list= {{{{21, 22}, 283}, {{26, 13}, 28}, {{32, 17}, 531}, {{31, 11}, 
187}, {{30, 9}, 154}, {{25, 12}, 377}, {{12, 16},
285}}, {{{20, 19}, 183}, {{11, 23}, 249}, {{18, 21},
174}, {{12, 21}, 513}, {{24, 23}, 233}, {{29, 20},
465}}, {{{18, 20}, 136}, {{13, 23}, 244}, {{19, 21},
228}, {{14, 16}, 453}, {{14, 22}, 201}, {{18, 22},
417}, {{10, 22}, 217}, {{17, 23}, 180}}, {{{22, 20},
123}, {{25, 17}, 210}, {{28, 10}, 536}, {{27, 13},
296}, {{19, 11}, 391}, {{23, 18}, 305}, {{24, 18}, 204}}}


Length /@ list

{7, 6, 8, 7}

问题是:

例如,我如何选择长度 > 7 的子列表。我一直在尝试很多 Position/Select 失败:-(

最佳答案

Select[list, Length@# > 7 &]  

编辑

如有疑问,您可以测试标准如何评估其参数。例如:

Select[{a, b, c}, Print]

或者在经典路径上多一点:

Reap@Select[{a, b, c}, Sow]

感谢 Brett 在下面的评论中提出的建议

关于select - Mathematica 中嵌套列表的条件选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7326688/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com