diff options
-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 $_")) |