最後活躍 1 day ago

An implementation of propagators in Nova.

修訂 014603f6cc513b00c2ad1393d2746cea9ece8d5a

propagators.nv 原始檔案 Playground
1|| :@include: lib/rpn.nv
2
3|| :: declare variables :: (a b c d)
4 :: c = b * a
5 :: d = c + a
6 :: a <- 3
7 :: b <- 2
8
9|:: $x <- $y|
10 :: set $x to $y
11 :: propagate variable $x
12
13|:: declare variables? :: $name| :: var $name
14|:: declare variables|
15
16|:: var $x :default value: $y?| :: $x = $y
17|:: var $x| :: $x = 0
18
19|:: $x = $y| :: set $x to $y
20|:: $z = $x $op $y|
21 :nodes: $op $x $y $z
22
23|:: set $x to $y :variables: $x $z|
24 :: reset variables
25 :variables: $x $y
26|:: set $x to $y :not found: $x|
27 :: reset variables
28 :variables: $x $y
29|:: set $x to $y?|
30 :: find $x
31
32|:: fetch the value of $x :variables: $x $y?|
33 :: reset variables
34 :values: $y
35|:: fetch the value of $x :not found: $x?|
36|:: fetch the value of $x?|
37 :: find $x
38
39|:: propagate variable $x|
40 :: fetch nodes that depend on $x
41 :: propagate changes
42 :: prime the network
43
44|:: propagate changes :dependencies: $op $x $y $z|
45 :: fetch the value of $y
46 :: fetch the value of $x
47 :: compute $op and store it in $z
48 :: propagate variable $z
49 :visited: $op $x $y $z
50
51|:: compute $op and store it in $z :@rpn data: $x|
52 :: set $z to $x
53|:: compute $op and store it in $z? :values: ($x $y)|
54 :@rpn: ($x $y $op)
55
56|:: fetch nodes that depend on $x? :nodes: $op $x $y $z|
57 :dependencies: $op $x $y $z
58|:: fetch nodes that depend on $x? :nodes: $op $y $x $z|
59 :dependencies: $op $y $x $z
60|:: fetch nodes that depend on $x? :nodes: $op $w $y $z|
61 :checked nodes: $op $w $y $z
62|:: fetch nodes that depend on $x|
63 :: reset nodes
64
65|:: find $x :variables: $x $y?|
66|:: find $x? :variables: $z $y|
67 :checked variables: $z $y
68|:: find $x|
69 :: reset variables
70 :not found: $x
71
72|:: reset variables? :checked variables: $x $y|
73 :variables: $x $y
74|:: reset variables|
75
76|:: reset nodes? :checked nodes: $op $x $y $z|
77 :nodes: $op $x $y $z
78|:: reset nodes|
79
80|:: prime the network? :visited: $op $x $y $z|
81 :nodes: $op $x $y $z
82|:: prime the network|
83