0
A
回答
2
你的问题有些不明确。你想如何决定哪个项目被改变?
我假设你想用索引来完成它, “第0个子列表的第0项”。那就是:
to-report replace-subitem [index1 index2 lists value]
let old-sublist item index1 lists
report replace-item index1 lists (replace-item index2 old-sublist value)
end
observer> show replace-subitem 0 0 [[1 2] [3 4] [5 1]] 99
observer: [[99 2] [3 4] [5 1]]
你也可以想象根据其他标准进行更换。例如,假设我们希望在一个子表的第一项改变所有的1的出现到99那么这就是:
to-report replace-first [old new the-list]
if first the-list = old
[ report replace-item 0 the-list new ]
report the-list
end
to-report replace-firsts [old new lists]
report map [replace-first old new ?] lists
end
observer> show replace-firsts 1 99 [[1 2] [3 4] [1 1]]
observer: [[99 2] [3 4] [99 1]]
很多其他的答案是可能的,这取决于到底是什么问题,你正在努力解决。
相关问题
- 1. 替换嵌套列表中的项目python
- 2. 在列表中用嵌套列表中的NA替换空列
- 3. Python嵌套列表 - 更改和替换单个项目
- 4. 在嵌套列表中查找项目
- 5. 在嵌套列表中添加项目?
- 6. R:在嵌套列表替换值
- 7. 如何在Laravel中列出嵌套表中的所有项目
- 8. 在Python中用dict替换嵌套列表中的值?
- 9. 如何在Sencha触摸列表中显示嵌套项目
- 10. 替换为嵌套列表(序言)
- 11. 如何转换在sklearn中使用的嵌套列表?
- 12. 如何显示Xamarin表单中的项目的嵌套列表?
- 13. 使用linq从多个嵌套列表中删除项目
- 14. CSS嵌套列表项目和替代背景
- 15. 如何在动态创建的列表中创建嵌套列表项目?
- 16. MSBuild在项目列表中如何做字符串替换
- 17. 用图像替换列表项目
- 18. 替换下拉列表中的项目
- 19. 替换列表中的项目
- 20. 如何删除由字段嵌套的列表中的项目
- 21. 如何查询嵌套列表中的项目?
- 22. jQuery拖动嵌套列表项目
- 23. 追加列表项目嵌套领域
- 24. MvvmCross RecylerView嵌套列表项目
- 25. JavaScript替换正在替换嵌套字
- 26. 如何用嵌套的childview替换嵌套的childview?
- 27. MongoDB - 替换嵌套数组中的项目
- 28. 如何在嵌套字符串中使用正则表达式进行替换?
- 29. 转换嵌套列表嵌套元组
- 30. 如何使用多个嵌套项目反序列化XML?