Clojure:减少过多函数时如何传递参数

Clojure:减少过多函数时如何传递参数,clojure,Clojure,从中,以下代码将删除空白并将“lol”替换为“lol” 现在,根据网站的说法,下面的代码reduce over函数与上面的代码相同 (defn clean [text] (reduce (fn [string string-fn] (string-fn string)) [s/trim #(s/replace % #"lol" "LOL")])) 问题:我不明白text参数是如何传递到reduce函数中的匿名函数的。如何编写类似的代码,将参数

从中,以下代码将删除空白并将“lol”替换为“lol”

现在,根据网站的说法,下面的代码reduce over函数与上面的代码相同

(defn clean
      [text]
      (reduce (fn [string string-fn] (string-fn string))
              [s/trim #(s/replace % #"lol" "LOL")]))

问题:我不明白
text
参数是如何传递到reduce函数中的匿名函数的。如何编写类似的代码,将参数
text
显式传递到reduce函数中的匿名函数中

函数
reduce
采用可选参数,即reduce的初始值。如果未提供,则使用最后一个参数的第一项(在本例中,这当然不起作用,但在具有与初始值相同的有效类型的输入序列时起作用)


这似乎是不正确的。@n如果
text
是函数向量前面的arg,那么它会起作用。我对这个问题做了更多的描述。请不要投反对票@noisesmith我已经尝试在函数向量之前添加
文本了。这不管用,凯。我犯了一个愚蠢的错误。我忘了首先实现
(需要'[clojure.string:as s])
。这就是它不起作用的原因。抱歉搞混了
(defn clean
      [text]
      (reduce (fn [string string-fn] (string-fn string))
              [s/trim #(s/replace % #"lol" "LOL")]))
user> (defn clean
        [text]
        (reduce (fn [string string-fn] (string-fn string))
                text
                [clojure.string/trim #(clojure.string/replace % #"lol" "LOL")]))
#'user/clean
user> (clean "My boa constrictor is so sassy lol!  ")
"My boa constrictor is so sassy LOL!"