aboutsummaryrefslogtreecommitdiff
path: root/test2.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--test2.lux (renamed from test2.lang)60
1 files changed, 44 insertions, 16 deletions
diff --git a/test2.lang b/test2.lux
index 13fabc59a..9e46012e3 100644
--- a/test2.lang
+++ b/test2.lux
@@ -1,5 +1,5 @@
(import java.lang.System)
-(require "./another" as another)
+## (require "./another" as another)
(definterface Function
(: apply (-> [java.lang.Object] java.lang.Object)))
@@ -73,26 +73,54 @@
## Ideally, this is what I want...
## (exec [yolo lol
-## #let [foo bar]
-## #when foo]
+## #let [foo (bar 1 2 3)]
+## #when true]
## (meme yolo foo))
-(defmacro (exec tokens)
- (case tokens
- (#Cons (#Tuple steps) (#Cons return #Nil))
- (if (= 0 (mod (length steps) 2))
- (fold (lambda [inner pair]
- (case pair
- [label computation]
- (` (bind (~ computation)
- (lambda [(~ label)] (~ inner))))))
- return
- (as-pairs steps))
- (#Text "Oh no!"))))
+#( (def (+ x y)
+ (jvm/i+ x y))
+
+ (def inc (+ 1))
+
+ (def (fold f init values)
+ (case values
+ #Nil
+ init
+ (#Cons x xs)
+ (fold f (f init x) xs)))
+
+ (def length (fold inc 0))
+
+ (def (mod dividend divisor)
+ (jvm/imod dividend divisor))
+
+ (def (= x y)
+ (.equals x y))
+
+ (def (as-pairs list)
+ (case list
+ (#Cons x (#Cons y list*))
+ (#Cons [x y] (as-pairs list*))
+
+ _
+ #Nil))
+
+ (defmacro (exec tokens)
+ (case tokens
+ (#Cons (#Tuple steps) (#Cons return #Nil))
+ (if (= 0 (mod (length steps) 2))
+ (fold (lambda [inner pair]
+ (case pair
+ [label computation]
+ (` (bind (~ computation)
+ (lambda [(~ label)] (~ inner))))))
+ return
+ (as-pairs steps))
+ (#Text "Oh no!")))) )#
## Program
(def (main args)
- (case (' ((~ "TROLOLOL")))
+ (case (' ((~ "Doing a slight makeover.")))
(#Form (#Cons (#Text text) #Nil))
(:: (:: System out) (println text))
))