}
}
+times(x, y){
+ return x * y;
+}
+
main(){
[Int] l1 = 1 : 2 : 3 : 4 : 5 : [];
- var c = foldr(plus, 0, l1);
- var d = map(plus(1), l1);
+ var c = foldr(times, 1, l1);
+ print(c);
+// var d = map(plus(1), l1);
}
Just (ADDR t arity) = tell [Instr "ldl" [Lit t] ""] >>| mapM_ g fs >>| pure ()
Just (LAB l _ fn) = tell
[Instr "ldc" [Lit fn] ""
+ ,Instr "sth" [] ""
,Instr "ldc" [Lit 0] ""
- ,Instr "stmh" [Lit 2] ""]
+ ,Instr "sth" [] ""
+ ,Instr "ajs" [Lit -1] ""]
g (FunExpr _ k es fs) = getAdressbook >>= \ab->case 'Map'.get k ab of
//Identifier points to function
Just (LAB l arity fn) = if (arity <> (length es))
,Instr "sub" [] ""
,Instr "str" [Raw "SP"] ""
,Instr "ldr" [Raw "RR"] ""
- //RR is nu goed
-// ,Instr "ajs" [Lit $ ~ (length es)] ""
-// ,Instr "ldl" [Lit t] ""
-// ,Instr "ldr" [Raw "RR"] "END OF HIGHERORDERFUNCALL"
- // ,Instr "ldl" [Lit t] ""
- // ,Instr "ldh" [Lit $ 1] ""
- // ,Instr "neg" [] ""
- // ,Instr "ldr" [Raw "SP"] ""
- // ,Instr "add" [] ""
- // ,Instr "ldc" [Lit arity] ""
- // ,Instr "sub" [] ""
- // ,Instr "str" [Raw "SP"] ""
]
)
Nothing = liftT (Left $ Error "Undefined function!!!")