aboutsummaryrefslogtreecommitdiff
path: root/test2.lang
diff options
context:
space:
mode:
authorEduardo Julian2015-01-03 11:24:14 -0400
committerEduardo Julian2015-01-03 11:24:14 -0400
commit661c70e4d786e7b2188564beddc586f1a50e4656 (patch)
treefe3aff74ffa526d455b7e22d7015573dc926f5f1 /test2.lang
parent212dd66966a873e3d7183b071f719ef58e4d88fe (diff)
The language officially has a name: Lux (stylized as "lux").
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))
))