Function 针对输入序列运行3-arg(etc)函数

Function 针对输入序列运行3-arg(etc)函数,function,clojure,sequence,Function,Clojure,Sequence,我正在尝试编写一些clojure,它构建了一个数据结构,该结构也将是有效的clojure代码。(注意,这里我没有构建宏:只是一个碰巧返回clojure代码的函数) 以下是我的工作要点: (defn create-clause [ property operator value ] (list (symbol operator) (symbol property) (symbol value)) ) (create-clause "b" "<" "5") 在这一结构中: [ (=

我正在尝试编写一些clojure,它构建了一个数据结构,该结构也将是有效的clojure代码。(注意,这里我没有构建宏:只是一个碰巧返回clojure代码的函数)

以下是我的工作要点:

(defn create-clause [  property operator value  ]
  (list (symbol operator) (symbol property) (symbol value))
)

(create-clause "b" "<" "5")
在这一结构中:

[ (= 1 1) (= 1 1) ]
(and (= 1 1) (= 1 1))
但现在我又被卡住了

编辑#3:

好吧,我到了那里-我已经结束了一个邪恶的混乱-但至少它的工作,我可以开始重构现在

(conj (seq (loop [ input [ "AccountType" "=" "current" , "Balance" "<" 5 ] output [] ]
  (if (= (count input) 0) output
  (recur (drop 3 input) (conj output (create-clause(take 3 input))))))) 'and)
(and (= AccountType "current") (< Balance 5))

(conj(seq)循环[input[“AccountType”“=”current”,“Balance”“
分区
将一个序列分块成一定大小:

(def s (partition 3 (range 6)))
; s => ((0 1 2) (3 4 5))
map
partial
apply
的组合将允许您调用您的方法:

(defn reorder [a b c] (list b c a))
(def reordered (map (partial apply reorder) s))
; reordered => ((1 2 0) (4 5 3))
然后用
结束这一切:

(conj reordered 'and)
; => (and (1 2 0) (4 5 3))

太好了-谢谢-我会在重构时研究这个问题-我刚刚找到了一个可行的解决方案,但它需要整理!很高兴看到我最终使用了conj'和bit,我一定做了一些正确的事情。。。!
(and [(< a 10) (< b 5)]) ; wrong - don't want that internal vector wrapper...
[ (= 1 1) (= 1 1) ]
(and (= 1 1) (= 1 1))
(conj (seq (loop [ input [ "AccountType" "=" "current" , "Balance" "<" 5 ] output [] ]
  (if (= (count input) 0) output
  (recur (drop 3 input) (conj output (create-clause(take 3 input))))))) 'and)
(and (= AccountType "current") (< Balance 5))
(def s (partition 3 (range 6)))
; s => ((0 1 2) (3 4 5))
(defn reorder [a b c] (list b c a))
(def reordered (map (partial apply reorder) s))
; reordered => ((1 2 0) (4 5 3))
(conj reordered 'and)
; => (and (1 2 0) (4 5 3))