[英]Clojure: How to use Mapping with an Anonymous Function?
(defn recurse
[temp total] ;total is: (and true true(and false))
(map (fn [i]
(cond
(seq? i) (println "");If total is not a single parenthesis (single sequence), recur until it is
(= i 'and) (System/exit 0) ;I want this to be called only when the **second** "and" is called
:else (println "This should never print I think")
))
idealreturn)
)
我想(系统/退出0)第二“和”在总检测而不是之前只有当被调用。 我该怎么做呢?
通过在数据上映射函数以对其进行转换,您走在正确的轨道上。 有几种方法可以获取您正在寻找的内容:
and
你看看是否已经有一个and
你正在构建的结果,如果and
已经存在,调用exit。为每件事赋予一个责任使代码更容易编写,并且编写后记既高效又容易。 当您稍后回来处理代码时,这对您来说也容易得多。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.