Rebinding a def can have unpredictable results in an environment that requires synchronization. Consider using refs, atoms, or agents, if you need to modify state.
You can accumulate values in a for loop like so
(defn chk-key-present-in-sos
""
[mapped-sos cmp-key cmp-seq-vals]
(if (seq-of-maps? mapped-sos)
(for [mapped-row mapped-sos
:let [matched-rows mapped-row]
:when (chk-one-val-present mapped-row cmp-key cmp-seq-vals)]
matched-rows)
nil))
You can use reduce to produce a final result.
(defn key-pres?
"This function accepts a value (cmp-val) and a vector of vectors
(parsed output from clojure-csv) and returns the match value
back if found and nil if not found.
Using reduce, the function searches every vector row to see
if cmp-val is at the col-idx location in the vector."
[cmp-val cmp-idx csv-data]
(reduce
(fn [ret-rc csv-row]
(if (= cmp-val (nth csv-row col-idx nil))
(conj ret-rc cmp-val)))
[]
csv-data))
And you can use into
to accumulate.
Finally, you can always use recursion and let the termination step return the
accumulated Fibonacci value.