Zuletzt aktiv 1 day ago

An implementation of propagators in Nova.

Änderung a63f6c83956082a2cbb15a2f6bf4006a5aa31d34

propagators.nv Originalformat 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|:: propagate changes|
51
52|:: compute $op and store it in $z :@rpn data: $x|
53 :: set $z to $x
54|:: compute $op and store it in $z? :values: ($x $y)|
55 :@rpn: ($x $y $op)
56
57|:: fetch nodes that depend on $x? :nodes: $op $x $y $z|
58 :dependencies: $op $x $y $z
59|:: fetch nodes that depend on $x? :nodes: $op $y $x $z|
60 :dependencies: $op $y $x $z
61|:: fetch nodes that depend on $x? :nodes: $op $w $y $z|
62 :checked nodes: $op $w $y $z
63|:: fetch nodes that depend on $x|
64 :: reset nodes
65
66|:: find $x :variables: $x $y?|
67|:: find $x? :variables: $z $y|
68 :checked variables: $z $y
69|:: find $x|
70 :: reset variables
71 :not found: $x
72
73|:: reset variables? :checked variables: $x $y|
74 :variables: $x $y
75|:: reset variables|
76
77|:: reset nodes? :checked nodes: $op $x $y $z|
78 :nodes: $op $x $y $z
79|:: reset nodes|
80
81|:: prime the network? :visited: $op $x $y $z|
82 :nodes: $op $x $y $z
83|:: prime the network|
84