Ok, I'm a bit stuck on this one, can I actually do what I'm trying to do with this part of the code below:
(recur (conj (get-links (first links)) (rest links))))
get-links returns a sequence of urls which is fed into the initial process-links call then should recurse.
The first link i feed in works, but then the second link where I'm trying to conj one sequence on to another gives me the following error.
"Clojure.lang.LazySeq@xxxxxxx"
Now I'm wondering, is this conj'ing the reference to the instruction to generate the "rest" (rest links) of the un-evaluated sequence?
(defn process-links
[links]
(if (not (empty? links))
(do
(if (not (is-working (first links)))
(do
(println (str (first links) " is not working"))
(recur (rest links)))
(do
(println (str (first links) " is working"))
(recur (conj (get-links (first links)) (rest links))))))))
If I'm totally wrong in my approach to this, let me know.
conj
adds an item to a collection. Using it on two collections creates a nested structure. You probably want to concat
the two sequences instead.
To illustrate:
user> (conj [1 2 3] [4 5 6])
[1 2 3 [4 5 6]]
user> (concat [1 2 3] [4 5 6])
(1 2 3 4 5 6)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With