Perhaps this exists already somewhere?
The helloworld of macros lets you do `(infix 1 + 2)`:
(defmacro infix [a op b] ~(,op ,a ,b))
(defmacro infix [& toks] (def prec {'+ 1 '- 1 '* 2 '/ 2 '% 2}) (var pos 0) (defn climb [min-p] (var left (toks pos)) (++ pos) (while (>= (get prec (get toks pos) -1) min-p) # nil/operand -> -1, stops the loop (def op (toks pos)) (++ pos) (set left ~(,op ,left ,(climb (inc (prec op)))))) # inc => left-associative left) (climb 0))
https://janet-lang.org/spork/api/infix.html
Perhaps this exists already somewhere?