on master help sign in
JETS
commit52e2a63f12961385dcb72da76059755949a4f6fa authoriko <mail@iko.soy> dateMon 21 Aug 2023, 13:14 (3 years ago) parent5a5eb7f
6 files changed+47−16
src/Nock.hs+5−4 src/Nock/Jets.hs+1−8 tests/golden/add.hoon+2−3 tests/golden/dec.hoon+3−1 tests/golden/mul.hoon+36 tests/golden/mul.nock
src/Nock.hs+5−4
@@ -70,6 +70,7 @@ fas n rhs =
7070 else fas 2 rest
7171
7272haxWord :: Word# -> Noun -> Noun -> Noun
73+haxWord _ _ tree | traceShow tree False = undefined
7374haxWord 1## newValue _ = newValue
7475haxWord place newValue ~(Cell lhs rhs _) =
7576 let a = uncheckedShiftRL# place 1#
@@ -106,10 +107,10 @@ tar' b c subject = case b of
106107 2## -> case x of
107108 ~(Cell l k _) -> case tar' l k subject of
108109 ~(formula@(Cell battery ~(Cell sample _ _) _)) ->
109− if traceShowId battery == Nock.Jets.add
110− then error "Found it!"
111− else case (tar' h j subject) of
112− ~(Cell u v _) -> tar' u v formula
110+ -- if traceShowId battery == Nock.Jets.add
111+ -- then error "Found it!"
112+ case (tar' h j subject) of
113+ ~(Cell u v _) -> tar' u v formula
113114 5## -> case x of
114115 ~(Cell l k _) -> tis (tar' h j subject) (tar' l k subject)
115116 7## -> case x of
src/Nock/Jets.hs+1−8
@@ -6,12 +6,5 @@ import Nock.Types
66dec :: Noun
77dec = Nock.Parser.noun "[8 [1 0] 8 [1 6 [5 [0 30] 4 0 6] [0 6] 9 2 10 [6 4 0 6] 0 1] 9 2 0 1]"
88
9−weirdDec = Nock.Parser.noun "[ 8 [ 1 [ 8 [1 0 0] [ 1 6 [5 [1 0] 0 12] [0 13] 9 2 10 [6 [8 [9 21 0 7] 9 2 10 [6 0 28] 0 2] 4 0 13] 0 1 ] 0 1 ] [ [1 2] 8 [1 0] [1 8 [1 0] 8 [1 6 [5 [0 30] 4 0 6] [0 6] 9 2 10 [6 4 0 6] 0 1] 9 2 0 1] 0 1 ] 1 1 ] 9 21 0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0 28] 0 2] 4 0 13] 0 1 ]"
tests/golden/add.hoon+2−3
@@ -1,9 +1,8 @@
1−.*
2−~
31!=
42=>
53|%
64++ foo 1
5+++ baz |= x=@ x
76++ dec
87|= a=@
98=/ b 0
@@ -22,4 +21,4 @@
2221 ?: =(0 a) b
2322 $(a (dec a), b +(b))
2423--
25−dec
24+(add 3 5)
tests/golden/dec.hoon+3−1
@@ -11,4 +11,6 @@
1111|- ^- @
1212?. =(a +(b)) $(b +(b)) b
1313--
14−dec
14+%-
15+dec
16+5
tests/golden/mul.hoonnew file+36
@@ -0,0 +1,36 @@
1+=>
2+|%
3+++ mul
4+ ~/ %mul
5+ :: unsigned multiplication
6+ ::
7+ :: a: multiplicand
8+ :: b: multiplier
9+ |: [a=`@`1 b=`@`1]
10+ :: product
11+ ^- @
12+ =+ c=0
13+ |-
14+ ?: =(0 a) c
15+ $(a (dec a), c (add b c))
16+++ foo 1
17+++ baz |= x=@ x
18+++ dec
19+|= a=@
20+=/ b 0
21+|- ^- @
22+?. =(a +(b)) $(b +(b)) b
23+++ bar 2
24+++ add
25+ :: ~/ %add
26+ :: unsigned addition
27+ ::
28+ :: a: augend
29+ :: b: addend
30+ |= [a=@ b=@]
31+ :: sum
32+ ^- @
33+ ?: =(0 a) b
34+ $(a (dec a), b +(b))
35+--
36+(mul 3 5)
tests/golden/mul.nocknew file

No changes to the content.