From 5f492cd8f612906d25f6377731f71c7289fd4b8d Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 28 Jan 2015 02:06:52 -0400 Subject: [Bug] - The analyser trying to match function calls first was messing around with variant construction. [Working on] - Monadic macros. --- source/lux.lux | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) (limited to 'source/lux.lux') 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'] -- cgit v1.2.3