Fork me on GitHub
Jim Strieter21:05:42

Right now I'm getting a vector of results from next-jdbc. Something like this:

[{:column 42} {:column 99} ...]
For what I'm doing, it would be more convenient to have a list. The reason is that I want to use every search result exactly once, deleting every map after it is used. For example:
;; do something with first result
(do-whatever {:column 42})
(recur (rest my-result-seq))
Here is my question: If I do something like this:
(into '() my-result-seq)
(apply list my-result-seq)
does that require O(N) overhead to make the transformation? Or can Clojure do that in O(1)?


(doseq [row results] ...) if you don’t care about the result. (run! do-whatever my-result-seq). The type vector vs list is almost meaningless for your purposes

Jim Strieter23:05:19

I don't understand the first half


I don't understand the question. What do you mean by "deleting every map"? It's a sequence of hash maps -- aren't you just going to iterate over it?


And if you only want to do a single pass over the results and process each row, perhaps plan would be better and then you don't even have the overhead of creating the hash maps or the vector?