This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-12
Channels
- # announcements (4)
- # asami (3)
- # babashka (18)
- # babashka-sci-dev (2)
- # beginners (55)
- # calva (18)
- # clj-commons (23)
- # clj-kondo (2)
- # cljfx (7)
- # cljs-dev (15)
- # clojure (96)
- # clojure-europe (43)
- # clojure-losangeles (3)
- # clojure-nl (2)
- # clojure-uk (11)
- # clojurescript (1)
- # datalevin (2)
- # datomic (10)
- # events (1)
- # google-cloud (4)
- # gratitude (16)
- # helix (3)
- # hyperfiddle (63)
- # inf-clojure (13)
- # introduce-yourself (4)
- # ipfs (2)
- # jobs (2)
- # jobs-discuss (12)
- # leiningen (7)
- # lsp (15)
- # off-topic (38)
- # polylith (24)
- # portal (27)
- # remote-jobs (8)
- # sci (27)
- # spacemacs (5)
- # specter (1)
- # sql (5)
- # xtdb (41)
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)?(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
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?