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?