Reputation: 6595
(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 ','
)
here is my output.
#<Ref@5a4e229e: #{#<Ref@3fc2e163: #{0}> #<Ref@63280c85: #{0 1}>}>
i would like to make implement AND operation that will return #{0}
and OR that will return #{0 1}.
my problem is how to access the lists i have created. I wasn't able to use union/intersection for some reason.
Upvotes: 1
Views: 64
Reputation: 81
You should deref all the inner sets and apply union to the new set it should look somthing like this:
(let [newList (ref #{})] (doseq [item @your_ref_to_set_of_refs] (dosync (alter newList conj @item))) (apply union @newList))
Upvotes: 3