Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我将如何获得类似于以下内容的内容?:
(evaluate-text "(+ 1 2)") ; resolves to 3
user> (eval (read-string "(+ 1 2)")) 3
你可能永远不需要这样做。宏和 fns 使这种事情在 99% 的时间里都是不必要的。这非常脆弱,如果这些字符串来自用户输入等,则可能是不安全的。
(load-string "(+ 1 2)")
它必须有多相似?Clojureeval在列表上工作,所以:
eval
(eval (list + 1 2)) #=> 3