Zuletzt aktiv 1759333592

A quick demonstration of building propagators from scratch.

june's Avatar june hat die Gist bearbeitet 1759333592. Zu Änderung gehen

1 file changed, 137 insertions

propagators.nv(Datei erstellt)

@@ -0,0 +1,137 @@
1 + ||:@include: lib/rpn.nv
2 +
3 + ||:: a = b + c
4 + ||:: d = a + # 1
5 + ||:: b = 1
6 + ||:: c = 2
7 +
8 + |:: $x = $y $op $z|
9 + :: create some cells :names: ($x $y $z)
10 + :: create an operator
11 + :operation: $op
12 + :inputs: $y $z
13 + :output: $x
14 +
15 + |:: $x = # $y $op $z|
16 + :: $x = $y $op $z
17 + :: set $y to $y
18 +
19 + |:: $x = $y $op # $z|
20 + :: $x = $y $op $z
21 + :: set $z to $z
22 +
23 + |:: $x = # $y $op # $z|
24 + :: $x = $y $op $z
25 + :: set $y to $y
26 + :: set $z to $z
27 +
28 + |:: $x = $y|
29 + :: change $x to $y
30 +
31 + |:: create a cell named $cell|
32 + :: create some cells :names: $cell
33 + |:: create some cells? :value: $cell $value|
34 + |:: create some cells? :value: $cell |
35 + |:: create some cells? :no such cell: $cell |
36 + :cells: $cell
37 + |:: create some cells? :names: $cell|
38 + :: fetch the value of $cell
39 + |:: create some cells|
40 +
41 + |:: fetch the value of $cell :cells: $cell $value?|
42 + :value: $cell $value
43 + :: reset cells
44 + |:: fetch the value of $cell :cells: $cell?|
45 + :value: $cell
46 + :: reset cells
47 + |:: fetch the value of $cell? :cells: $ $value|
48 + :checked cells: $ $value
49 + |:: fetch the value of $cell? :cells: $|
50 + :checked cells: $
51 + |:: fetch the value of $cell|
52 + :no such cell: $cell
53 + :: reset cells
54 +
55 + |:: reset cells? :checked cells: $cell $value|
56 + :cells: $cell $value
57 + |:: reset cells? :checked cells: $cell|
58 + :cells: $cell
59 + |:: reset cells|
60 +
61 + |:: create an operator
62 + :operation: $operation
63 + :inputs: $first $second
64 + :output: $output
65 + |:operators: $operation $first $second $output
66 +
67 + |:: change $cell to $value|
68 + :: set $cell to $value
69 + :: propagate $cell
70 +
71 + |:: set $cell to $value :cells: $cell $|
72 + :cells: $cell $value
73 + :: reset cells
74 + |:: set $cell to $value :cells: $cell|
75 + :cells: $cell $value
76 + :: reset cells
77 + |:: set $cell to $value? :cells: $x $y|
78 + :checked cells: $x $y
79 + |:: set $cell to $value? :cells: $|
80 + :checked cells: $
81 + |:: set $cell to $value|
82 + :: create a cell named $cell
83 + :: change $cell to $value
84 +
85 + |:: propagate $cell|
86 + :: search for an operator that takes $cell as an input
87 + :: unpack that operator
88 + :: perform the operation
89 +
90 + |:: search for an operator that takes $cell as an input
91 + :operators: $op $cell $second $output?
92 + |
93 +
94 + |:: search for an operator that takes $cell as an input
95 + :operators: $op $first $cell $output?
96 + |
97 +
98 + |:: search for an operator that takes $cell as an input?
99 + :operators: $op $first $second $output
100 + |:checked operators: $op $first $second $output
101 +
102 + |:: search for an operator that takes $cell as an input|
103 + :no operator found:
104 + :: reset operators
105 +
106 + |:: reset operators? :checked operators: $op $first $second $output|
107 + :operators: $op $first $second $output
108 + |:: reset operators|
109 +
110 + |:: unpack that operator :no operator found:|
111 + |:: unpack that operator :operators: $op $first $second $output?|
112 + :operation: $op
113 + :output: $output
114 + :: fetch the value of $first
115 + :: fetch the value of $second
116 + :: reset operators
117 +
118 + |:: perform the operation :@rpn data: $value :output: $cell|
119 + :: change $cell to $value
120 + |:: perform the operation?
121 + :operation: $op
122 + :value: $c1 $v1
123 + :value: $c2 $v2
124 + |:@rpn: ($v2 $v1 $op)
125 + |:: perform the operation
126 + :operation: $op
127 + :value: $c1 $
128 + :value: $c2
129 + :output: $o
130 + |
131 + |:: perform the operation
132 + :operation: $op
133 + :value: $c1
134 + :value: $c2 $
135 + :output: $out
136 + |
137 + |:: perform the operation|
Neuer Älter