pyra nested loops
· 891 B · Text
Raw
Playground
| EXAMPLE USAGE
* create a 3x3 grid of cubes
- loop ~ from: 0 0 0 ~ to: 2 2 2 - by: 1
- create cubelets
* create cubelets * done:
| create cubelets \ indices: I J K
- create a cube at I J K
- iterate
| NESTED LOOP RULESET ( works for any number of nested loops )
| loop * from: N
- temporary: N
* loop - setup loop
| setup loop * temporary: N
- from: N
- indices: N
* setup loop
| iterate
* indices: Max * from: Min * to: Max
- seen indices: Min
- seen min: Min
- seen max: Max
* iterate
* indices: I | by: Increment
- reset the indices
^ fact('indices', str(int(I) + int(Increment)))
* iterate
- done:
- clear the indices
| reset the indices
* seen indices: I * seen min: Min * seen max: Max
- indices: I
- from: Min
- to: Max
* reset the indices
| clear the indices
* seen indices: I * seen min: Min * seen max: Max
* clear the indices
| 1 | | EXAMPLE USAGE |
| 2 | |
| 3 | |
| 4 | * create a 3x3 grid of cubes |
| 5 | - loop ~ from: 0 0 0 ~ to: 2 2 2 - by: 1 |
| 6 | - create cubelets |
| 7 | |
| 8 | * create cubelets * done: |
| 9 | |
| 10 | | create cubelets \ indices: I J K |
| 11 | - create a cube at I J K |
| 12 | - iterate |
| 13 | |
| 14 | |
| 15 | |
| 16 | | NESTED LOOP RULESET ( works for any number of nested loops ) |
| 17 | |
| 18 | |
| 19 | | loop * from: N |
| 20 | - temporary: N |
| 21 | |
| 22 | * loop - setup loop |
| 23 | |
| 24 | | setup loop * temporary: N |
| 25 | - from: N |
| 26 | - indices: N |
| 27 | |
| 28 | * setup loop |
| 29 | |
| 30 | | iterate |
| 31 | * indices: Max * from: Min * to: Max |
| 32 | - seen indices: Min |
| 33 | - seen min: Min |
| 34 | - seen max: Max |
| 35 | |
| 36 | * iterate |
| 37 | * indices: I | by: Increment |
| 38 | - reset the indices |
| 39 | ^ fact('indices', str(int(I) + int(Increment))) |
| 40 | |
| 41 | * iterate |
| 42 | - done: |
| 43 | - clear the indices |
| 44 | |
| 45 | | reset the indices |
| 46 | * seen indices: I * seen min: Min * seen max: Max |
| 47 | - indices: I |
| 48 | - from: Min |
| 49 | - to: Max |
| 50 | |
| 51 | * reset the indices |
| 52 | |
| 53 | | clear the indices |
| 54 | * seen indices: I * seen min: Min * seen max: Max |
| 55 | |
| 56 | * clear the indices |