You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,7 +63,7 @@ Reports a random agent from <tt><i>agentset</i></tt>.
63
63
64
64
The probability of each agent being picked is proportional to the weight given by the <tt><i>reporter</i></tt> for that agent. The weights must not be negative.
65
65
66
-
If the agentset is empty, it reports [`nobody`](http://ccl.northwestern.edu/netlogo/docs/dictionary.html#nobody).
66
+
If the agentset is empty, it reports [`nobody`](https://docs.netlogo.org/dictionary.html#nobody).
67
67
68
68
Here is a full rewrite of the **Lottery Example** model using the `rnd:weighted-one-of` primitive:
69
69
@@ -141,7 +141,7 @@ If all weights are `0.0`, each candidate has an equal probability of being picke
141
141
142
142
Reports a random item from <tt><i>list</i></tt>.
143
143
144
-
The probability of each item being picked is proportional to the weight given by the <tt><i>anonymous-reporter</i></tt> for that item. The weights must not be negative. The first argument passed to the anonymous procedure refers to the list item. (See the [Anonymous Procedures section](/programming.html#anonymous-procedures) of the Programming Guide for more details.)
144
+
The probability of each item being picked is proportional to the weight given by the <tt><i>anonymous-reporter</i></tt> for that item. The weights must not be negative. The first argument passed to the anonymous procedure refers to the list item. (See the [Anonymous Procedures section](https://docs.netlogo.org/programming.html#anonymous-procedures) of the Programming Guide for more details.)
145
145
146
146
It is an error for the list to be empty.
147
147
@@ -158,15 +158,15 @@ repeat 25 [
158
158
159
159
This should print `B` roughly four times more often than it prints `A`.
160
160
161
-
If you happen to have your items and your weights in two separate lists, you can combine them into pairs by using a combination of [`map`](http://ccl.northwestern.edu/netlogo/docs/dictionary.html#map) and [`list`](http://ccl.northwestern.edu/netlogo/docs/dictionary.html#list):
161
+
If you happen to have your items and your weights in two separate lists, you can combine them into pairs by using a combination of [`map`](https://docs.netlogo.org/dictionary.html#map) and [`list`](https://docs.netlogo.org/dictionary.html#list):
162
162
163
163
```
164
164
let items [ "A" "B" "C" ]
165
165
let weights [ 0.1 0.2 0.7 ]
166
166
let pairs (map list items weights)
167
167
```
168
168
169
-
Since we apply [`map`](http://ccl.northwestern.edu/netlogo/docs/dictionary.html#map) to both the `items` list and the `weights` list, the parentheses are needed in `(map list items weights)`. We also use the concise anonymous procedure syntax (see the [programming guide](http://ccl.northwestern.edu/netlogo/docs/programming.html#anonymous-procedures)) to pass [`list`](http://ccl.northwestern.edu/netlogo/docs/dictionary.html#list) as the reporter for [`map`](http://ccl.northwestern.edu/netlogo/docs/dictionary.html#map). The same thing could have been written `(map [ [a b] -> list a b ] items weights)`.
169
+
Since we apply [`map`](https://docs.netlogo.org/dictionary.html#map) to both the `items` list and the `weights` list, the parentheses are needed in `(map list items weights)`. We also use the concise anonymous procedure syntax (see the [programming guide](https://docs.netlogo.org/programming.html#anonymous-procedures)) to pass [`list`](https://docs.netlogo.org/dictionary.html#list) as the reporter for [`map`](https://docs.netlogo.org/dictionary.html#map). The same thing could have been written `(map [ [a b] -> list a b ] items weights)`.
170
170
171
171
172
172
@@ -180,13 +180,13 @@ Since we apply [`map`](http://ccl.northwestern.edu/netlogo/docs/dictionary.html#
180
180
181
181
Reports a list of the given <tt><i>size</i></tt> randomly chosen from the <tt><i>list</i></tt> of candidates, with no repeats.
182
182
183
-
The probability of each item being picked is proportional to the weight given by the <tt><i>anonymous-reporter</i></tt> for that item. The weights must not be negative. The first argument passed to the anonymous procedure refers to the list item. (See the [Anonymous Procedures section](/programming.html#anonymous-procedures) of the Programming Guide for more details.)
183
+
The probability of each item being picked is proportional to the weight given by the <tt><i>anonymous-reporter</i></tt> for that item. The weights must not be negative. The first argument passed to the anonymous procedure refers to the list item. (See the [Anonymous Procedures section](https://docs.netlogo.org/programming.html#anonymous-procedures) of the Programming Guide for more details.)
184
184
185
185
It is an error for <tt><i>size</i></tt> to be greater than the size of the <tt><i>list</i> of candidates</tt>.
186
186
187
187
If, at some point during the selection, there remains only candidates with a weight of `0.0`, they all have an equal probability of getting picked.
188
188
189
-
The items in the resulting list appear in the same order that they appeared in the list of candidates. (If you want them in random order, use [`shuffle`](http://ccl.northwestern.edu/netlogo/docs/dictionary.html#shuffle) on the result).
189
+
The items in the resulting list appear in the same order that they appeared in the list of candidates. (If you want them in random order, use [`shuffle`](https://docs.netlogo.org/dictionary.html#shuffle) on the result).
190
190
191
191
Example:
192
192
```
@@ -208,15 +208,15 @@ This should print a list of four numbers, where the bigger numbers (32, 64, 128,
208
208
209
209
Reports a list of the given <tt><i>size</i></tt> randomly chosen from the <tt><i>list</i></tt> of candidates, with repeats.
210
210
211
-
The probability of each item being picked is proportional to the weight given by the <tt><i>anonymous-reporter</i></tt> for that item. The weights must not be negative. The first argument passed to the anonymous procedure refers to the list item. (See the [Anonymous Procedures section](/programming.html#anonymous-procedures) of the Programming Guide for more details.)
211
+
The probability of each item being picked is proportional to the weight given by the <tt><i>anonymous-reporter</i></tt> for that item. The weights must not be negative. The first argument passed to the anonymous procedure refers to the list item. (See the [Anonymous Procedures section](https://docs.netlogo.org/programming.html#anonymous-procedures) of the Programming Guide for more details.)
212
212
213
213
It is **not** an error for <tt><i>size</i></tt> to be greater than the size of the <tt><i>list</i></tt> of candidates, but there has to be at least one candidate.
214
214
215
215
If, at some point during the selection, there remains only candidates with a weight of `0.0`, they all have an equal probability of getting picked.
216
216
217
217
If all weights are `0.0`, each candidate has an equal probability of being picked.
218
218
219
-
The items in the resulting list appear in the same order that they appeared in the list of candidates. (If you want them in random order, use [`shuffle`](http://ccl.northwestern.edu/netlogo/docs/dictionary.html#shuffle) on the result).
219
+
The items in the resulting list appear in the same order that they appeared in the list of candidates. (If you want them in random order, use [`shuffle`](http://docs.netlogo.org/dictionary.html#shuffle) on the result).
0 commit comments