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.
我想要以下结果: "1" -> true "0" -> false nil -> nil
如何改进此功能?
#(when-not (nil? %) (if % "1" "0"))
您的需求直接转换为地图,地图也可以作为 Clojure{1 true, 0 false}中的函数调用,您想要的函数也是如此。
{1 true, 0 false}
({1 true, 0 false} 1) ;;=> true ({1 true, 0 false} 0) ;;=> false ({1 true, 0 false} nil) ;;=> nil