2015-10-07 22 views
1

我只是嘗試在netlogo中使用foreach。 有5站,我想使用列表並創建與每個始發站和目標站的鏈接。foreach在netlogo中使用不能工作,它只是預期的命令

有我的代碼。我檢查並始終得到「預期命令」。

to link_list 
    let origin_list [1 3] 
    let destination_list [2 5] 
    foreach origin_list destination_list [ 
    ask stations [ 
     if id = ?1 [ 
     create-links-with stations with [id = ?2]]]] 
end 

任何一種專家都可以幫助我。 PLZ

回答

1

要使用foreach在兩個列表同時,整個呼叫必須用括號:

`(foreach list1 list2 [ ... ])` 

這是任何原始的NetLogo接受可變數量的參數也是如此。總是有一些默認的參數,沒有parens;任何其他數字都需要parens。

+0

非常感謝你。我可以繼續我的工作。 – Redone

相關問題