Welcome! Please see the About page for a little more info on how this works.
How can I parse the abstract syntax tree from a function? For instance, given
(defn f [x] (/ (- 1.0 (Math/exp (- x))) 2.0))
Is there some way to parse it into a datastructure like a list:
[:op "/" [:op "-" 1.0 [:op "Math/exp" [:op "-" x]]] 2.0]
Thanks!
P.S.: I understand that this is almost the same . I am trying to learn Clojure and this seems to be trivial problem, but I can't find a solution.
Hello! There is a useful library for such tasks called tools.analyzer that would be of service. The link is https://github.com/clojure/tools.analyzer