(defn GetValuesFromWhereCommand
"return a list of values from Where command"
[Query tableName]
(let [values (re-seq #"[0-9a-zA-Z_=<>]+" ((re-find #"WHERE(.*)" Query) 1))
bitwise (re-find #"AND|OR" Query)
tempList (ref #{})
]
; first loop will look for the operators = < >
(doseq [item values]
(let [result (case (re-find #"[=><]" item)
"=" (GetRowsfromCondition tableName item = )
"<" (GetRowsfromCondition tableName item < )
">" (GetRowsfromCondition tableName item > )
nil (println "nothing")
)]
(when (not= nil result) (dosync (alter tempList conj result)) )
tempList)
)
(println tempList)
tempList) ; get the Where from Update ','
)
这是我的输出。
#<Ref@5a4e229e: #{#<Ref@3fc2e163: #{0}> #<Ref@63280c85: #{0 1}>}>
我想进行返回#{0}的实现AND操作 和OR将返回#{0 1}。
我的问题是如何访问我创建的列表。由于某种原因,我无法使用联合/交叉。
答案 0 :(得分:3)
您应该deref所有内部集并将union应用于新集 看起来应该是这样的:
(let [newList (ref #{})] (doseq [item @your_ref_to_set_of_refs] (dosync (alter newList conj @item))) (apply union @newList))