macro
boot.janet on line 1174, column 1
(-> x & forms)
Threading macro. Inserts x as the second value in the first form in
forms, and inserts the modified first form into the second form in
the same manner, and so on. Useful for expressing pipelines of
data.
(-> "X"
(string "a" "b")
(string "c" "d")
(string "e" "f")) # => "Xabcdef"
(->
{:a [1 2 3] :b [4 5 6]}
(get :a)
(sum)
(string " is the result"))
# -> "6 is the result"
# same as:
(string (sum (get {:a [1 2 3] :b [4 5 6]} :a))" is the result")
(-> 1 (< 2)) # -> true
(->> 1 (< 2)) # -> false
(-> 1 (+ 2) (+ 3)) # -> 6
(defn inc [x] (+ x 1))
(defn inv [x] (* x -1))
(defn sq [x] (* x x))
(-> 2 inc) # -> 3
(-> 2 inc inc) # -> 4
(-> 2 inc inc inv) # -> -4
(-> 2 inc inc inv sq) # -> 16