NetLogo Help: up-to-n-of

### up-to-n-of6.1

#### up-to-n-of size agentset up-to-n-of size list

From an agentset, reports an agentset of size size randomly chosen from the input set, with no repeats. If the input does not have enough agents to satisfy the size, reports the entire agentset.

From a list, reports a list of size size randomly chosen from the input set, with no repeats. The items in the result appear in the same order that they appeared in the input list. (If you want them in random order, use shuffle on the result.) If the input does not have enough items to satisfy the size, reports the entire list.

If size is fractional, it will be rounded down to the nearest integer (4.5 becomes 4, 10.9 becomes 10).

    ask up-to-n-of 50 patches [ set pcolor green ]
    ;; 50 randomly chosen patches turn green
    ;; if less than 50 patches exist, they all turn green

See also n-of, one-of.

Take me to the full NetLogo Dictionary