diff options
author | Eduardo Julian | 2015-01-28 02:06:52 -0400 |
---|---|---|
committer | Eduardo Julian | 2015-01-28 02:06:52 -0400 |
commit | 5f492cd8f612906d25f6377731f71c7289fd4b8d (patch) | |
tree | 838b229e25dae64babaa3224fc8fcea30d09b4c7 /source/lux.lux | |
parent | de427e2de39159863fbb9ca9d9984faa1cf60b02 (diff) |
[Bug]
- The analyser trying to match function calls first was messing around with variant construction.
[Working on]
- Monadic macros.
Diffstat (limited to '')
-rw-r--r-- | source/lux.lux | 43 |
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'] |