2017-05-25 209 views
0

我有一個列表列表(裏面有一個座標列表),並希望通過內部列表的內容進行過濾,如果它與我想刪除的結果相匹配。我無法迭代列表,然後列表第二列表。Netlogo fore if with if語句

DATA:

[[14.142135623730951 [-2 -16] "15"] [13.601470508735444 [-4 -17] "15"] [21.93171219946131 [-4 -17] "16"] [27.294688127912362 [-4 -17] "14"] [15.524174696260024 [-4 -17] "13"]] 

我嘗試:

set coords [-4 -17] 
    foreach[distanceQueue] 
    [ 
    if(item ? item 1 distanceQueue = coords)[set distanceQueue remove-item ? distanceQueue] 

    ] 

item ?應foreach循環和第1項的當前迭代應該是陣列的第二元件。

任何人都可以協助我完成這項工作嗎?

回答

2

這聽起來像是你要求filter。例如,

to-report test 
    let lst [ 
    [14.142135623730951 [-2 -16] "15"] 
    [13.601470508735444 [-4 -17] "15"] 
    [21.93171219946131 [-4 -17] "16"] 
    [27.294688127912362 [-4 -17] "14"] 
    [15.524174696260024 [-4 -17] "13"] 
    ] 
    let coords [-4 -17] 
    report filter [[?] -> coords != item 1 ?] lst 
end