我有一个列表,listIn用n多个元素调用.我有另一个列表,ind用melements(m<n)调用它.ind是我想要保留的指数listIn,并删除其他指数.
我可以通过运行循环来做到这一点,但我很好奇是有一种聪明的方法来做到这一点.
例如.
listIn = [0,1,2,3,4,5,6,7,8,9,10]; // 11 elements
ind = [4,7,8] // 3 indices
Result = drop all elements excepts ones at 4,7,8.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
38 次 |
| 最近记录: |