Miguel Pais
Miguel Pais

Reputation: 65

NetLogo 6 and the rnd extension

I am trying to update my model to NL 6 because the automatic update failed (mostly due to syntax for anonymous procedures). My model uses the rnd extension which now apparently comes bundled with NetLogo, but the example from the manual still mentions this:

extensions[rnd]

to go

  let pairs [ [ "A" 0.2 ] [ "B" 0.8 ] ]
repeat 25 [
  ; report the first item of the pair selected using
  ; the second item (i.e., `last ?`) as the weight
  type first rnd:weighted-one-of-list pairs [ last ? ]
]

end

This results in an error because "nothing named ? has been defined". I have been able to convert other things like foreach and n-values, but I am struggling with this example to the new notation required by NetLogo 6. Can someone help?

Upvotes: 2

Views: 169

Answers (1)

Nicolas Payette
Nicolas Payette

Reputation: 14972

We missed a few cases when converting the rnd extension manual for bundling it with NetLogo. This will be fixed in NetLogo 6.0.1. In the meanwhile, you can refer to the most current version of the manual on GitHub:

https://github.com/NetLogo/Rnd-Extension/blob/hexy/README.md

In your specific case, the NetLogo 6 syntax would be:

rnd:weighted-one-of-list pairs [ [p] -> last p ]

Upvotes: 2

Related Questions