The Lab
Write a Vex chain, or start from a preset. The Lab reads the chain as you type, evaluates it at each record of the space, and draws the result at each record. Select a record to see the trace of the evaluation there.
Four boxes on graph paper: a record space. Drag a box to change the results.
The Lab reads the chain as you type. It knows root, const lines and arrow functions.
ops of Num at A:
The result at each of the 4 records
| 5 | |
| 5 | |
| 7.28 | |
| 6.32 |
The trace at A
- ref position @A → (2, 2)
- var $0 @B → (2, 2)
- ref position @B → (6, 5)
- app distance @B → 5
- var $0 @C → (2, 2)
- ref position @C → (13, 3)
- app distance @C → 11.05
- var $0 @D → (2, 2)
- ref position @D → (4, 11)
- app distance @D → 9.22
- each others @A → [B: 5, C: 11.05, D: 9.22]
- let $0 @A → [B: 5, C: 11.05, D: 9.22]
- app min @A → 5
The program as JSON
{
"tag": "app",
"op": "min",
"args": [
{
"tag": "let",
"bind": {
"$0": {
"tag": "ref",
"path": [
"position"
]
}
},
"body": {
"tag": "each",
"axis": {
"t": "others"
},
"body": {
"tag": "app",
"op": "distance",
"args": [
{
"tag": "var",
"name": "$0"
},
{
"tag": "ref",
"path": [
"position"
]
}
]
}
}
}
]
}How the Lab works
Section titled “How the Lab works”- Four spaces. The boxes are a record space. Life is a grid space. The organization chart is a tree space. The rows are an array space. Each space has its own moves and axes.
- A safe reader. The Lab does not run your text as JavaScript. A small reader reads the chain:
constlines, calls, arrow functions and literals. It permits only the members of the builder, so a shared link cannot run other code. - The ops of the current value. Under the editor, the chips show the ops of the domain of the result at the origin. A chip adds the op to the end of the chain. After an axis, the chips show the reductions of the list.
- A link for each program. “Copy link” puts the space and the code in the address of the page. The link opens the same program.
- Programs are data. The last panel shows the program as JSON: the same tree that
serializegives.
The boxes are the same four boxes as the other pages. Drag a box in the Lab, and the results change.