最后活跃于 3 weeks ago

june's Avatar june 修订了这个 Gist 3 weeks ago. 转到此修订

1 file changed, 36 insertions

forall.nv(文件已创建)

@@ -0,0 +1,36 @@
1 + ||:@include: lib/rpn.nv
2 +
3 + |:: push $x to $y|
4 + :stacks: $y $x
5 + |:: pop from $x :stacks: $x $y|
6 + :item: $y
7 + |:: pop from $x? :stacks: $y $z|
8 + :seen: $y $z
9 + |:: pop from $x|
10 + :stack empty: $x
11 + :: reset stacks
12 +
13 + |:: reset stacks? :seen: $x $y|
14 + :stacks: $x $y
15 + |:: reset stacks|
16 +
17 + |:: $x for all $y :stack empty: $y|
18 + |:: $x for all $y?|
19 + :: pop from $y
20 + :: apply $x
21 + |:: $x all $y| :: $x for all $y
22 +
23 + |:: apply $x :stack empty: $y?|
24 + |:: apply $x :item: $y|
25 + :: $x $y
26 +
27 + |:: sum $x :@rpn data: $y| :total: $y
28 + |:: sum $x? :total: $y|
29 + :@rpn: ($x $y +)
30 + |:: sum $x?|
31 + :total: 0
32 +
33 + ||:: push 10 to numbers
34 + :: push 20 to numbers
35 + :: push 30 to numbers
36 + :: sum all numbers
上一页 下一页