-
Notifications
You must be signed in to change notification settings - Fork 6
/
macro_expanded_code.tmp
33 lines (33 loc) · 1.05 KB
/
macro_expanded_code.tmp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
(core-define "log" <macro([item])>:
(do (print "log: ") (println item))
</macro>)
(log "hello-world")
(if (= (+ 1 1) (- 3 1 0)) (println "true") (println "false"))
(println (call/cc <fn([ret])>:
(ret "hello, call/cc!")
</fn>))
(display "abc" 234)
(newline)
(core-set "l1" (list "a1" "b2" "c2"))
(do (print "list l1 is") (println l1))
(do (print "length of l1 is") (println (count l1)))
(do (print "the 3rd of l1 is") (println (nth l1 2)))
(println "fibonacci test:")
(core-define "hello" <fn([name])>:
(do (print "Hello") (println name))
</fn>)
(hello "World!")
(core-define "fib" <fn([n])>:
(if (< n 3) 1 (+ (fib (- n 1)) (fib (- n 2))))
</fn>)
(do (print "fib 15 =") (println (fib 15)))
(core-define "say-hi" <fn([msg, name])>:
(do (print msg) (println name))
</fn>)
(say-hi "welcome" "zoowii")
(println (+ 1 2 3 4 5))
(println "hashmap test")
(core-define "m1" (hashmap (list "a" "b" "c") (list "hello" list 123)))
(println m1)
(do (print (hashmap-get m1 "a")) (print (hashmap-get m1 "c")) (println (hashmap-get m1 "d" "not found return value")))
(println "世界\n你好")