### one-of

#### one-of agentset
one-of list

From an agentset, reports a random agent. If the agentset is empty, reports nobody.

From a list, reports a random list item. It is an error for the list to be empty.

    ask one-of patches [ set pcolor green ]
    ;; a random patch turns green
    ask patches with [any? turtles-here]
      [ show one-of turtles-here ]
    ;; for each patch containing turtles, prints one of
    ;; those turtles

    ;; suppose mylist is [1 2 3 4 5 6]
    show one-of mylist
    ;; prints a value randomly chosen from the list

See also n-of.

Take me to the full NetLogo Dictionary