diff options
author | Eduardo Julian | 2017-09-04 20:10:43 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-09-04 20:10:43 -0400 |
commit | 4808ec4dd27afc06fb949166ce2ba7c52657feff (patch) | |
tree | 86ac3a0daf592e2abda72b3952c02731376f20fd | |
parent | 8e6c5fc029178674275758f7c68425b13a473208 (diff) |
- $_ and _$ macros now handle better "operator" code that is a form. e.g.
($_ (::: +) 1 2 3) => (::: + 1 (::: + 2 3)) instead of ((::: +) 1 ((::: +) 2 3))
-rw-r--r-- | stdlib/source/lux.lux | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index d29e4fca5..641e8693d 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -1485,6 +1485,16 @@ #Nil ys)) +(def:''' (_$_joiner op a1 a2) + #;Nil + (-> Code Code Code Code) + (_lux_case op + [_ (#Form parts)] + (form$ (List/append parts (list a1 a2))) + + _ + (form$ (list op a1 a2)))) + (macro:' #export (_$ tokens) (#Cons [["lux" "doc"] (#TextA "## Left-association for the application of binary functions over variadic arguments. (_$ Text/append \"Hello, \" name \".\\nHow are you?\") @@ -1496,9 +1506,7 @@ (#Cons op tokens') (_lux_case tokens' (#Cons first nexts) - (return (list (fold (function' [a1 a2] (form$ (list op a1 a2))) - first - nexts))) + (return (list (fold (_$_joiner op) first nexts))) _ (fail "Wrong syntax for _$")) @@ -1517,9 +1525,7 @@ (#Cons op tokens') (_lux_case (reverse tokens') (#Cons last prevs) - (return (list (fold (function' [a1 a2] (form$ (list op a1 a2))) - last - prevs))) + (return (list (fold (_$_joiner op) last prevs))) _ (fail "Wrong syntax for $_")) |