NetLogo Lists and Conditional Change

I want to selectively modify some elements of the list, but not all, depending on whether members satisfy certain conditions. For example, in a list of values, I want to subtract 9 from all values ​​that are greater than 9.

I tried

set nodeext2 map nodeext2 [ifelse-value (? > 9)  [? - 9][?]]

But we get the "expected constant" error. I also tried if-else and played using brackets. Can someone help me? I feel that this is probably clearly indicated somewhere, but I could not find where.

+4
source share
1 answer

You simply inverted the order of the arguments map: the reporter must come before the list. Try:

set nodeext2 map [ifelse-value (? > 9)  [? - 9][?]] nodeext2

" " ifelse-value, , map , , [ifelse-value (? > 9) [? - 9][?]] ( , , ifelse-value ).

+4

Source: https://habr.com/ru/post/1525216/


All Articles