i am fairly new to clojure and would like to know why when i convert a set to a vector, the resultant vector is a vector of nested vectors.
For instance, i have this collection of type Lazy Seq
(#{:fox :corn} #{:boat} #{})
This is as a result of running,
(map #(disj (set %) :goose :you) [[:fox :goose :corn :you] [:boat] []])
I want to loop through the collection and get the vector
[[:fox :corn] [:boat] []]
but the best code i was able to come up with was
(for [i non-vec] (conj (empty []) (vec i)))
where 'non-vec' is the above Lazy sequence.
However running the command produces the following
([[:fox :corn]] [[:boat]] [[]])
which is of type Lazy sequence too.
I would like to know
1: How to get the intended vector
2: Why the output is of type Lazy Sequence while i conjoined it to an empty vector
Question one: I think you're looking for
(mapv vec '(#{:fox :corn} #{:boat} #{})) ;; [[:fox :corn] [:boat] []]
Question two:
I think that's because for
yields a lazy sequence