Skip to content

Commit 70ae901

Browse files
committed
Update with and let docs.
Remove descendent docs
1 parent 5d08727 commit 70ae901

1 file changed

Lines changed: 4 additions & 57 deletions

File tree

README.md

Lines changed: 4 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ LevelSpace is an extension for NetLogo that allows you to run several models con
2727

2828
## LevelSpace fundamentals
2929

30-
LevelSpace must be loaded in a model using the ```extensions [ls]``` command. Once this is done, a model will be able to load up other models using the LevelSpace primitives, run commands and reporters in them, and close them down when they are no longer needed.
30+
LevelSpace must be loaded in a model using ```extensions [ls]``` at the top of your model. Once this is done, a model will be able to load up other models using the LevelSpace primitives, run commands and reporters in them, and close them down when they are no longer needed.
3131

3232
Asking and reporting in LevelSpace is conceptually pretty straight forward: You pass blocks of code to child models, and the child models respond as if you had typed that string into their Command Center. LevelSpace allows you to report strings, numbers, and lists from a child to its parent. It is not possible to directly report turtles, patches, links, or any of their respective sets. Further, it is not possible to push data from a child to its parent - parents must ask their children to report.
3333

@@ -107,18 +107,12 @@ let turtle-id 0
107107
(ls:report model-id [ [ color ] of turtle ? ] turtle-id)
108108
```
109109

110-
####`ls:ask-descendent` _list_ _string-of-commands_
110+
#### _list_ `ls:with` _reporter-block_
111111

112-
####(`ls:ask-descendent` _list_ _string-of-commands_ _arguments_ ...)
113-
114-
####_reporter-string_ `ls:of-descendent` _list_
115-
116-
Like `ls:ask` and `ls:of`, but the list specifies a model at an arbitray place down the tree of models. This is useful when you child models that have child models that have child models and so forth.
117-
118-
For the hierarchical primitives, the list is read from left to right, and the reporter or command is passed down through the hierarchy. For instance, if we want to ask model 0's child model 1 to ask its child model 9 to call its `setup`, we would write
112+
Reports a new list of models containing only those models that report true when they run the reporter block.
119113

120114
```
121-
ls:ask-descendent [0 1 9] "setup"
115+
ls:models ls:with [ count turtles > 100 ]
122116
```
123117

124118
####`ls:let` _variable-name_ _data_
@@ -191,15 +185,6 @@ to go
191185
end
192186
```
193187

194-
### 'with' in LevelSpace.
195-
The best way to do the equivalent of `with` in LevelSpace is to combine `filter` with `ls:of`. Let's for instance say that we only want the models that satisfy a set of particular criteria. For example:
196-
197-
```
198-
ls:ask (filter [[ count turtles > 5 ] ls:of ?]) [
199-
ask turtles [ fd 1 ]
200-
]
201-
```
202-
203188
### Caveats for `ls:let`
204189

205190
`ls:let` is very similar to `let`, except in a few cases.
@@ -253,44 +238,6 @@ ls:ask ls:models [
253238

254239
All models will print `1`.
255240

256-
#### You cannot access ls variables from inside tasks
257-
258-
This behavior should be considered a bug and not relied upon.
259-
260-
For example, this gives an error:
261-
262-
```
263-
ls:let my-var 5
264-
ls:ask model-id [
265-
run task [
266-
show my-var
267-
]
268-
]
269-
```
270-
271-
The following won't error, but will give unexpected results:
272-
273-
```
274-
ls:let my-var 5
275-
ls:ask model-id [
276-
(run task [ show foo + ? ] 7)
277-
]
278-
```
279-
280-
The child model will show 14 instead of 12.
281-
282-
Fortunately, there is an easy workaround in the case of `ls:ask`:
283-
284-
```
285-
ls:let my-var 5
286-
ls:ask model-id [
287-
let var my-var
288-
run task [
289-
show var
290-
]
291-
]
292-
```
293-
294241
#### `ls:let` does not respect the scope of `if`, `when`, and `repeat`
295242

296243
This behavior should be considered a bug and not relied upon. It is an unfortunate consequence of the way the NetLogo engine works. Hopefully, we'll be able to correct this in a future version of NetLogo.

0 commit comments

Comments
 (0)