NetLogo Lists and Conditional Modification
dictionary, foreach, if-statement, netlogo
Solution
You simply inverted the order of the `map` arguments: the reporter must come before the list. Try:
set nodeext2 map [ifelse-value (? > 9) [? - 9][?]] nodeext2
You were getting the "Expected a constant" message on `ifelse-value` because the compiler expected the second argument of `map` to be a list and were thus trying to interpret `[ifelse-value (? > 9) [? - 9][?]]` as one (and failing because lists are made of constants, which `ifelse-value` is not).
Problem
I want to selectively modify some members of a list but not all depending on whether the members satisfy some condition. For instance, 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 get an 'expected a constant'-error. I have also tried if-else and playing around with brackets. Can anyone help me? I feel as if this is probably clearly stated somewhere but I haven't been able find where.