I am brand new to NetLogo, and trying to use a model written for v5 on v6, and hit some conversion challenges.
From reading the docs, the replacement of ? with anonymous functions seems easy enough to understand, however most examples I have seen seem focused on foreach loops, and not enough mention of sort-by. When I apply the conversion that I think ought to work, I hit an error that suggests a literal is expected.
I have a challenge with these 2 loops in particular
#loop-1
foreach sort-by [[who] of ?1 < [who] of ?2] aset[ ]
#loop-2
foreach sort-by [ ?1 < ?2 ] bset [ ]
If I rewrite both as follows, I get an error that a literal is expected
#loop-1
foreach sort-by [[?1 ?2] -> [[who] of ?1 > [who] of ?2]] aset [ ]
#loop-2
foreach sort-by [[?1 ?2] -> [ ?1 < ?2 ]] bset [ ]
Would appreciate any suggestions.
I think I figured this out now. These work ... I needed to get rid of the '?'
#loop-1
foreach sort-by [[a b] -> [[who] of a > [who] of b]] aset [ ]
#loop-2
foreach sort-by [[x y] -> x < y ] bset [ ]