Macro want to use symbol instead of string in clojure -


so trying make haskell lambda syntax, , macro i've got:

(defmacro / [& all]   (let [args (take-while #(not (= %1 "=>")) all)         argcount (count args)         expr (last (split-at (+ argcount 1) all))]     `(fn ~(vec args) (~@expr))))  (reduce (/ x y "=>" + x y) [1 2 3]) 

this works enough, last thing i'd make don't need "=>" can use =>

any tips how might make => valid symbol can parse in context i'm referring?

compare name of symbol against string:

(defmacro / [& all]   (let [args (take-while #(not (= (name %1) "=>")) all)         argcount (count args)         expr (last (split-at (+ argcount 1) all))]     `(fn ~(vec args) (~@expr)))) 

Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -