aboutsummaryrefslogtreecommitdiff
path: root/source/lux.lux
diff options
context:
space:
mode:
authorEduardo Julian2015-01-28 02:06:52 -0400
committerEduardo Julian2015-01-28 02:06:52 -0400
commit5f492cd8f612906d25f6377731f71c7289fd4b8d (patch)
tree838b229e25dae64babaa3224fc8fcea30d09b4c7 /source/lux.lux
parentde427e2de39159863fbb9ca9d9984faa1cf60b02 (diff)
[Bug]
- The analyser trying to match function calls first was messing around with variant construction. [Working on] - Monadic macros.
Diffstat (limited to 'source/lux.lux')
-rw-r--r--source/lux.lux43
1 files changed, 37 insertions, 6 deletions
diff --git a/source/lux.lux b/source/lux.lux
index 1a5317991..c40c26589 100644
--- a/source/lux.lux
+++ b/source/lux.lux
@@ -84,6 +84,37 @@
(fold f (f init x) xs)
)))))
+(annotate lambda Macro)
+(def' lambda
+ (lambda' _ tokens
+ (case tokens
+ (#Cons self (#Cons (#Tuple (#Cons arg args')) (#Cons body #Nil)))
+ (#Form (#Cons (#Ident "lambda'")
+ (#Cons self
+ (#Cons arg
+ (case args'
+ #Nil
+ (#Cons body #Nil)
+
+ _
+ (#Cons (#Ident "lux:lambda")
+ (#Cons (#Tuple args')
+ (#Cons body #Nil))))))))
+
+ (#Cons (#Tuple (#Cons arg args')) (#Cons body #Nil))
+ (#Form (#Cons (#Ident "lambda'")
+ (#Cons (#Ident "_")
+ (#Cons arg
+ (case args'
+ #Nil
+ (#Cons body #Nil)
+
+ _
+ (#Cons (#Ident "lux:lambda")
+ (#Cons (#Tuple args')
+ (#Cons body #Nil))))))))
+ )))
+
#(
(defmacro (lambda tokens)
(case tokens
@@ -232,16 +263,16 @@
(let length (jvm:invokevirtual String "length" []
text [])
(map (lambda' idx
- (jvm:invokevirtual String "charAt" [int]
- text [idx]))
+ (jvm:invokevirtual String "charAt" [int]
+ text [idx]))
(range 0 length))))
(def (enumerate list)
(case (fold (lambda' state
- (lambda' x
- (case state
- [idx list']
- [(inc idx) (#Cons [idx x] list')])))
+ (lambda' x
+ (case state
+ [idx list']
+ [(inc idx) (#Cons [idx x] list')])))
[0 #Nil]
list)
[_ list']