Considering:
user=> (require '[babashka.process :refer [shell]])
nil
user=> (def j
(-> (shell {:out :string :err "/dev/null"} "ls")
:out some-func))
I understand that {:out :string :err "/dev/null"}
is a map of a kind of options used to mold behavior for the shell command to run.
Then, at the next line.
:out
, I understand it's a keyword that corresponds to stdout. I also know that it can be used to retrieve the corresponding value from a map.
But I don't understand how :out some-func
can be used to call the function some-func
.
Where does the macro ->
place the result of the line (shell ...)
? I suppose that after :out
. So, the :out
value would be extracted from the map of results of the (shell...)
line, but how is it used as argument to some-func
?
It is not even inside parenthesis. Why not?
The so-called "thread first" ->
macro does two things:
(...)
(-> (a) (b) (c) ...)
becomes (... (c (b (a))))
So in your case, the result is (some-func (:out (shell ...)))
.