2 - compound functions

This commit is contained in:
Kartik K. Agaram 2014-07-06 01:53:18 -07:00
parent c72d831021
commit a1fe0ff3c7
3 changed files with 18 additions and 4 deletions

8
mu.arc
View File

@ -19,9 +19,11 @@
add
(= memory*.oarg1
(+ memory*.arg1 memory*.arg2))
; else
(prn "aaa") ; user-defined functions go here
))))
; else user-defined function
(run function*.op)
)))
;? (prn "return")
)
(awhen cdr.argv
(each file it

View File

@ -8,3 +8,16 @@
(run function*!test1)
(if (~iso memory* (obj 1 1 2 3 3 4))
(prn "F - load and add instructions work"))
(clear)
(add-fns
'((add-fn
(3 <- add 1 2))
(main
(1 <- loadi 1)
(2 <- loadi 3)
(_ <- add-fn))))
(run function*!main)
;? (prn memory*)
(if (~iso memory* (obj 1 1 2 3 3 4))
(prn "F - compound functions work"))

1
x.mu
View File

@ -2,5 +2,4 @@
(1 <- loadi 1)
(2 <- loadi 3)
(3 <- add 1 2)
(x <- prn a)
)