diff options
author | Eduardo Julian | 2015-01-11 17:55:14 -0400 |
---|---|---|
committer | Eduardo Julian | 2015-01-11 17:55:14 -0400 |
commit | 7f076e6ca1a107b6b0ce54784e9b9eb2ae715771 (patch) | |
tree | 5d4a83f39cdb814d37bf03dc9c9aae853ddd1490 /test2.lux | |
parent | a315700f4fb7b981fff3bab0a29de0ec53fc1e6b (diff) |
- Added integer remainder.
- Now, can handle boolean returns from methods.
- Static functions now define a "_datum" field containing an empty instance.
- Fixed a bug when analysing lambdas that made their arguments get treated like they were closure variables.
Diffstat (limited to 'test2.lux')
-rw-r--r-- | test2.lux | 47 |
1 files changed, 30 insertions, 17 deletions
@@ -67,6 +67,10 @@ [java.lang.Object _5] [java.lang.Object _6] [java.lang.Object _7] [java.lang.Object _8]]) +(def (println x) + (jvm/invokevirtual java.io.PrintStream "println" [Object] + (jvm/getstatic System out) [x])) + (def (++ xs ys) (case xs #Nil @@ -139,22 +143,26 @@ (def inc (+ 1)) -#( (def (fold f init values) - (case values - #Nil - init - (#Cons x xs) - (fold f (f init x) xs))) +(def (id x) + x) - (def length (fold inc 0)) +(def (fold f init values) + (case values + #Nil + init + (#Cons x xs) + (fold f (f init x) xs))) - (def (mod dividend divisor) - (jvm/imod dividend divisor)) +(def length (fold (lambda [l x] (inc l)) 0)) - (def (= x y) - (.equals x y)) +(def (rem dividend divisor) + (jvm/irem dividend divisor)) - (def (as-pairs list) +(def (= x y) + (jvm/invokevirtual Object "equals" [Object] + x [y])) + +#( (def (as-pairs list) (case list (#Cons x (#Cons y list*)) (#Cons [x y] (as-pairs list*)) @@ -175,10 +183,6 @@ (as-pairs steps)) (#Text "Oh no!")))) )# -(def (println x) - (jvm/invokevirtual java.io.PrintStream "println" [Object] - (jvm/getstatic System out) [x])) - ## Program (def (main args) (case (' ((~ "Oh yeah..."))) @@ -188,7 +192,16 @@ (println (inc 10)) (println (jvm/i- 10 20)) (println (jvm/i* 10 20)) - (println (jvm/i/ 10 2))) + (println (jvm/i/ 10 2)) + (let list (#Cons 1 (#Cons 2 (#Cons 3 (#Cons 4 (#Cons 5 (#Cons 6 #Nil)))))) + (do (println (fold + 0 list)) + (println (length list)))) + (println (rem 21 6)) + (println (rem 21 7)) + (println (= false false)) + (println (= false true)) + (println (= true false)) + (println (= true true))) )) #( (def (main args) |