Fork me on GitHub
#sql
<
2022-05-12
>
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)
or
(apply list my-result-seq)
does that require O(N) overhead to make the transformation? Or can Clojure do that in O(1)?

dpsutton22:05:31

(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

seancorfield23:05:48

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?

seancorfield23:05:08

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?