JanetDocsPlaygroundI'm feeling luckyGitHub sign in

->



    macro
    boot.janet on line 1118, 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.


4 examplesSign in to add an example
Loading...
(->
  {: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")
felixrPlayground
(->  1 (< 2))   # -> true
(->> 1 (< 2))   # -> false
cellularmitosisPlayground
(-> 1 (+ 2) (+ 3))  # -> 6
cellularmitosisPlayground
(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
cellularmitosisPlayground