How are you enjoying java.lang.String in clojure

How can I go to the next?

(defn run-clojure-func []
  (println "welcome"))

(defn -main [& args]
  (eval (*func* (first args)))

java exam.Hello "run-clojure-func"
+3
source share
1 answer

Two versions for you are completely equivalent, but useful as comparison points:

(defn -main [& args]
  ((-> args first symbol resolve)))

and this, using destructuring and ->macro usage:

(defn -main [[fn-name]]
  ((resolve (symbol fn-name))))

resolve- this is obviously the key. Documents are your friend. :-) Just like an unfair generalization, it is evalalmost never required.

+7
source

Source: https://habr.com/ru/post/1767999/


All Articles