Commit 97aff46b authored by Job Cuppen's avatar Job Cuppen

corrections

parent 10b552e3
......@@ -23,7 +23,7 @@
.depend "StdOverloaded" "20191001141536"
.depend "StdBool" "20191001141536"
.depend "StdEnv" "20191001141536"
.module m_ex1 "ex1" "20191007153506"
.module m_ex1 "ex1" "20191010135755"
.endinfo
.impmod _system
.implab _cycle_in_spine
......@@ -228,16 +228,10 @@ n21
ea21
.o 3 0
s21
buildh _Nil 0
push_a 1
buildAC "]"
buildh ARRAY 1
buildh _Cons 2
push_a 2
push_a 1
update_a 1 2
update_a 0 1
pop_a 1
build e_StdList_d++ 2 e_StdList_n++
buildh d10 0
push_a 2
push_a 1
......
......@@ -22,7 +22,7 @@
.depend "StdOverloaded" "20191001141536"
.depend "StdBool" "20191001141536"
.depend "StdEnv" "20191001141536"
.module m_ex3 "ex3" "20191007152946"
.module m_ex3 "ex3" "20191010140318"
.endinfo
.impmod _system
.implab _cycle_in_spine
......@@ -60,174 +60,55 @@
.implab n_S.6 ea_S.6
.implab _driver
.impmod StdList
.impdesc e_StdList_d++
.implab e_StdList_n++ e_StdList_ea++
.impmod StdString
.impdesc e_StdString_dtoString;5
.implab e_StdString_ntoString;5
.implab e_StdList_sisMember;51
.impmod StdInt
.implab e_StdInt_s<;17
.desc d15 _hnf _hnf 0 0 "Leaf"
.desc d16 _hnf _add_arg 3 0 "Bin"
.record r17 aaa 3 0 "Container;"
.impdesc e_StdInt_d<;17
.impmod StdOverloaded
.impdesc e_StdOverloaded_r<;
.desc d14 _hnf _hnf 0 0 "Leaf"
.desc d15 _hnf _add_arg 3 0 "Bin"
.record r16 aaaa 4 0 "Container;"
.export __ex3_Start
.o 0 0
__ex3_Start
build _ 0 n1
.d 1 0
jmp _driver
.n 0 _ ea1
.n 0 _
.o 1 0
n1
push_node _cycle_in_spine 0
.o 1 0
.d 0 0
jsr ea1
.o 0 1 b
fillB_b 0 0
pop_b 1
.d 1 0
rtn
.o 0 0
ea1
.o 1 0
.o 0 0
s1
buildh d15 0
create
buildI 4
push_a 2
update_a 2 3
update_a 0 2
pop_a 1
.d 3 0
jsr s9
.o 1 0
create
buildh _Nil 0
buildI 3
buildh _Cons 2
buildI 2
push_a 2
update_a 2 3
update_a 0 2
pop_a 1
.d 3 0
jsr s9
.o 1 0
create
buildh _Cons 2
buildI 1
push_a 2
update_a 2 3
update_a 0 2
pop_a 1
.d 3 0
jsr s9
.o 1 0
create
buildI 3
push_a 2
update_a 2 3
update_a 0 2
pop_a 1
.d 3 0
jsr s9
.o 1 0
create
buildI 5
push_a 2
update_a 2 3
update_a 0 2
pop_a 1
.d 3 0
jsr s9
.o 1 0
.d 2 0
jmp s10
.n 1 _ ea10
.o 1 0
n10
push_node _cycle_in_spine 1
.o 2 0
ea10
jsr_eval 0
.o 2 0
s10
eq_desc d15 0 0
jmp_true case.1
jmp case.2
case.1
buildh _Nil 0
buildAC "🍁"
buildh ARRAY 1
fillh _Cons 2 3
pop_a 1
.d 1 0
rtn
case.2
repl_args 3 3
push_a 2
build _ 1 n10
push_a 2
build _ 1 e_StdString_ntoString;5
buildh _Cons 2
push_a 1
build _ 1 n10
build e_StdList_d++ 2 e_StdList_n++
buildAC "🌳"
buildh ARRAY 1
fillh _Cons 2 5
pop_a 3
.d 1 0
rtn
.n 2 _ ea9
.o 1 0
n9
push_node _cycle_in_spine 2
.o 3 0
ea9
jsr_eval 1
.o 3 0
s9
eq_desc d15 0 1
jmp_true case.3
jmp case.4
case.3
buildh d15 0
buildh d15 0
push_a 2
buildh e_StdInt_d<;17 0
buildI 33
push_a 1
update_a 1 2
update_a 0 1
pop_a 1
fillh d16 3 5
pop_a 2
.d 1 0
rtn
case.4
push_args 1 3 3
buildh _Nil 0
update_a 0 5
pop_a 1
push_a 3
jsr_eval 0
pushI_a 4
pop_a 1
push_a 1
jsr_eval 0
pushI_a 2
pop_a 1
ltI
jmp_false else.5
push_a 2
push_a 4
build _ 2 n9
.d 3 0
jmp s10
.o 3 0
s10
push_a 2
push_a 2
fillh d16 3 8
pop_a 5
.d 1 0
rtn
else.5
push_a 0
push_a 4
build _ 2 n9
push_a 3
push_a 3
push_a 2
update_a 2 3
update_a 1 2
update_a 0 1
pop_a 1
fillh d16 3 8
pop_a 5
.d 1 0
rtn
update_a 1 4
updatepop_a 0 3
.d 2 0
jmp e_StdList_sisMember;51
No preview for this file type
......@@ -22,8 +22,11 @@ instance serialize Int where
read [x : xs] = Just (toInt x, xs)
read _ = Nothing
NilString ::= "Nil"
instance serialize [a] | serialize a where
write l c = ["["] ++ flatMap write l ++ ["]"] ++ c
//write l c = ["["] ++ flatMap write l ++ ["]":c]
write [] c = [NilString:c]
read ["[":xs] = readHelper xs []
where
......@@ -78,4 +81,6 @@ where
intLeaf :: Bin Int
intLeaf = Leaf
//t = [1,2,3]
//Start = [55,66:t]
Start = map test [[1, 2], [5, 6]]
No preview for this file type
......@@ -12,7 +12,7 @@ class Container t where
instance Container [] where
Cinsert e l = [e:l]
Ccontains e l = foldr (||) False (map ((==) e) l)
Ccontains e l = isMember e l //foldr (||) False (map ((==) e) l)
Cshow l = map toString l
Cnew = []
......@@ -23,14 +23,15 @@ instance Container Bin where
| otherwise = Bin (Cinsert e l) a r
Ccontains e Leaf = False
Ccontains e (Bin l a r) =
e == a || Ccontains e l || Ccontains e r
Ccontains e (Bin l a r)
| e == a = True
| e > a = Ccontains e r
| otherwise = Ccontains e l
Cshow Leaf = ["🍁"]
Cshow (Bin l e r) = ["🌳": Cshow l ++ [toString e: Cshow r]]
Cnew = Leaf
//Start = Ccontains 3 [1,2,3]
Start = Cshow (Cinsert 5 (Cinsert 3 (Cinsert 1 (Cinsert 2 (Cinsert 4 Leaf)))))
//Start = foldr (+) 0 [1,2,3]
\ No newline at end of file
Start = Ccontains [1,2,3]
//Start = Cshow (Cinsert 5 (Cinsert 3 (Cinsert 1 (Cinsert 2 (Cinsert 4 Leaf)))))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment