Fork me on GitHub
#beginners
<
2021-09-26
>
Benjamin06:09:48

• Can I make some setting so print pretty prints for the rest of the repl session? ---

(with-out-str
  (for [name ["hurr"]]
    (println name)))
why does this not return "hurr" as string? I figured out it's because for makes a lazy seq but I'm not sure what a good alternative is, then. I can call seq and it works

Ed09:09:50

The equivalent of for in c style languages is doseq. However, your writing code that is joining a list of strings together and returning a single string. So you could use clojure.string/join. Other things to think about is that for is equivalent to map and (apply str ["foo" "bar"]) will return "foobar". println is a side-effecting function that prints something on standard out and returns nil ... When learning Clojure, it helps to get into the mindset of using a REPL (preferably from within your editor) to call functions that return values with no side effects as much as possible, and push all the side effects to the edges of your program.

Benjamin13:09:47

I see thanks. So str/join is the way here

👍 1
Tobias Sjögren08:09:41

Hi, from what I heard there should be Datomic channel here, can’t find it though..

andy.fingerhut10:09:57

There is at least one channel called #datomic

🙌 1
Benjamin13:09:38

Is there an equilavent to when-some that also checks for empty? ? Or is it a bad sign to want such a thing?

emccue14:09:45

(when-some (seq ...) ...)