Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Clojure 对数据应用一系列函数_Clojure - Fatal编程技术网

Clojure 对数据应用一系列函数

Clojure 对数据应用一系列函数,clojure,Clojure,我希望对数据应用一系列函数,如管道: 我知道它有->和->,而且我很难定义内部函数 (defn create ([code error] {:statusCode code :error error}) ([code error & [message data]] (create code error) - I want pipe it result to a function that check if

我希望对数据应用一系列函数,如管道:

我知道它有
->
->
,而且我很难定义内部函数

(defn create
  ([code error] {:statusCode code :error error})
  ([code error & [message data]]
   (create code error) - I want pipe it result
                       to a function that check if 
                       message if defined then merge with
                       {:message message}, then
                       apply to a function that checks if data
                       is defined an merge with it
))
您可以使用仅合并定义的变量:

(defn创建
([代码错误]
{:状态代码:错误})
([代码错误和[消息数据]]
(条件->(创建代码错误)
消息(关联:消息消息消息)
数据(关联:数据)
或者,如果定义了
助手,您可以定义小型
关联,并使用普通
->
线程宏:

(如果定义,则定义为defn-assoc
[m k v]
(如果(无)m(关联m k v)))
(defn创建
([代码错误]
{:状态代码:错误})
([代码错误和[消息数据]]
(>(创建代码错误)
(如果定义了关联:消息)
(如果定义了关联:数据)))