JanetDocsPlaygroundI'm feeling luckyGitHub sign in

seq



    macro
    boot.janet on line 590, column 1

    (seq head & body)

    Similar to loop, but accumulates the loop body into an array and 
    returns that. See loop for details.


4 examplesSign in to add an example
Loading...
(seq [i :range [0 3]
      j :range [0 3]
      :let [c (string/format "%c" (+ 97 i))]
      :when (and (even? i) (even? j))]
  [(keyword c) j])
# => '@[(:a 0) (:a 2) (:c 0) (:c 2)]
sogaiuPlayground
(seq [i :range [0 3]
      j :range [0 3]
      :let [c (string/format "%c" (+ 97 i))]]
  [(keyword c) j])
# => '@[(:a 0) (:a 1) (:a 2) (:b 0) (:b 1) (:b 2) (:c 0) (:c 1) (:c 2)]
sogaiuPlayground
(seq [i :range [0 3]
      j :range [0 3]]
  [(keyword (string/format "%c" (+ 97 i)))
   j])
# => '@[(:a 0) (:a 1) (:a 2) (:b 0) (:b 1) (:b 2) (:c 0) (:c 1) (:c 2)]
sogaiuPlayground
(seq [i :range [0 10] :when (odd? i)] (math/pow 2 i))

# => @[2 8 32 128 512]
# array with 2 to the power of all odd numbers smaller than 10
pepePlayground