search.nv
· 1.0 KiB · Text
Исходник
Playground
||:: insert :items: (1 2 foo 3 4)
:: search :for: (1 2 3 4 foo 1 2 3 4 bar)
||:@include: lib/rpn.nv
|:: insert? :items: $x|
:front: $x
|:: insert|
|:: search? :for: $x|
:: search for $x
|:: search|
|:: search for $x :found: $x? :bounce:|
|:: search for $x :found: $x?|
|:: search for $x? :target: front? :front: $x?|
:found: $x
:: count a step
|:: search for $x? :target: front? :front: $y|
:back: $y
:: count a step
|:: search for $x? :target: back? :back: $x?|
:found: $x
:: count a step
|:: search for $x? :target: back? :back: $y|
:front: $y
:: count a step
|:: search for $x :target: front :bounce:|
:target: back
:not found: $x
:: count a step
|:: search for $x :target: back :bounce:|
:target: front
:not found: $x
:: count a step
|:: search for $x? :target: front|
:target: back
:bounce:
|:: search for $x? :target: back|
:target: front
:bounce:
|:: search for $x?|
:target: front
|:: count a step :@rpn data: $x|
:steps: $x
|:: count a step? :steps: $x|
:@rpn: ($x 1 +)
|:: count a step?|
:steps: 0
| 1 | ||:: insert :items: (1 2 foo 3 4) |
| 2 | :: search :for: (1 2 3 4 foo 1 2 3 4 bar) |
| 3 | |
| 4 | ||:@include: lib/rpn.nv |
| 5 | |
| 6 | |:: insert? :items: $x| |
| 7 | :front: $x |
| 8 | |:: insert| |
| 9 | |
| 10 | |:: search? :for: $x| |
| 11 | :: search for $x |
| 12 | |:: search| |
| 13 | |
| 14 | |:: search for $x :found: $x? :bounce:| |
| 15 | |:: search for $x :found: $x?| |
| 16 | |
| 17 | |:: search for $x? :target: front? :front: $x?| |
| 18 | :found: $x |
| 19 | :: count a step |
| 20 | |:: search for $x? :target: front? :front: $y| |
| 21 | :back: $y |
| 22 | :: count a step |
| 23 | |
| 24 | |:: search for $x? :target: back? :back: $x?| |
| 25 | :found: $x |
| 26 | :: count a step |
| 27 | |:: search for $x? :target: back? :back: $y| |
| 28 | :front: $y |
| 29 | :: count a step |
| 30 | |
| 31 | |:: search for $x :target: front :bounce:| |
| 32 | :target: back |
| 33 | :not found: $x |
| 34 | :: count a step |
| 35 | |:: search for $x :target: back :bounce:| |
| 36 | :target: front |
| 37 | :not found: $x |
| 38 | :: count a step |
| 39 | |
| 40 | |:: search for $x? :target: front| |
| 41 | :target: back |
| 42 | :bounce: |
| 43 | |:: search for $x? :target: back| |
| 44 | :target: front |
| 45 | :bounce: |
| 46 | |
| 47 | |:: search for $x?| |
| 48 | :target: front |
| 49 | |
| 50 | |:: count a step :@rpn data: $x| |
| 51 | :steps: $x |
| 52 | |:: count a step? :steps: $x| |
| 53 | :@rpn: ($x 1 +) |
| 54 | |:: count a step?| |
| 55 | :steps: 0 |