Language Reference
Every built-in function, special form, and macro in the mino language. Organized by category with usage examples from the test suite.
Arithmetic
+
(+ 1 2)⇒
3(+ 1 2.5)⇒
3.5(+ x__bt 1)⇒
42-
42⇒
42"hi"⇒
"hi"nil⇒
nil*
(* 2 3 4)⇒
24[vx__ct (+ vx__ct 1) (* vx__ct vx__ct)]⇒
[7 8 49]{:n mx__ct, :sq (* mx__ct mx__ct)}⇒
{:n 7, :sq 49}/
(/ 10 4)⇒
2.5mod
(mod 10 3)⇒
1(mod -10 3)⇒
2(mod 5.5 2.0)⇒
1.5rem
(mod 10 3)⇒
1(mod -10 3)⇒
2(mod 5.5 2.0)⇒
1.5quot
(mod 10 3)⇒
1(mod -10 3)⇒
2(mod 5.5 2.0)⇒
1.5Comparison
=
(loop (n 100 acc 0) (if (= n 0) acc (recur (- n 1) (+ acc n))))⇒
5050<
(loop (i 0) (if (< i 50000) (recur (+ i 1)) i))⇒
50000(count (loop (i 0 acc []) (if (< i 2000) (recur (+ i 1) (conj acc i)) acc)))⇒
2000(get (loop (i 0 m {}) (if (< i 300) (recur (+ i 1) (assoc m i (* i 3))) m)) 150)⇒
450compare
(compare 1 2)⇒
-1(compare 5 5)⇒
0(compare 10 3)⇒
1Math
math-floor
(math-floor 3.7)⇒
3.0(math-floor 3.0)⇒
3.0(math-floor -3.2)⇒
-4.0math-ceil
(math-ceil 3.2)⇒
4.0(math-ceil 3.0)⇒
3.0(math-ceil -3.2)⇒
-3.0math-round
(math-round 3.5)⇒
4.0(math-round 3.4)⇒
3.0(math-round -3.5)⇒
-4.0math-sqrt
(math-sqrt 16)⇒
4.0(math-sqrt 0)⇒
0.0(math-sqrt 1)⇒
1.0math-pow
(math-pow 2 10)⇒
1024.0(math-pow 5 0)⇒
1.0(math-pow 2 3)⇒
8.0math-log
(math-log 1)⇒
0.0(math-exp 0)⇒
1.0math-exp
(math-exp 0)⇒
1.0math-sin
(math-sin 0)⇒
0.0math-cos
(math-cos 0)⇒
1.0math-tan
(math-tan 0)⇒
0.0math-atan2
(math-atan2 0 1)⇒
0.0Bitwise
bit-and
(bit-and 12 10)⇒
8bit-or
(bit-or 12 10)⇒
14bit-xor
(bit-xor 12 10)⇒
6bit-not
(bit-not 0)⇒
-1bit-shift-left
(bit-shift-left 1 4)⇒
16bit-shift-right
(bit-shift-right 16 2)⇒
4List
car
(car (quote (1 2 3)))⇒
1(car (source (quote sq-src__rt)))⇒
(quote def)cdr
(cdr (quote (1 2 3)))⇒
(quote (2 3))cons
(cons 1 (quote (2 3)))⇒
(quote (1 2 3))(first (lazy-seq (cons 1 nil)))⇒
1(rest (lazy-seq (cons 1 (cons 2 nil))))⇒
(quote (2))Collection
count
(count big)⇒
2000(count big2)⇒
(count big)(count m)⇒
200nth
(+ (nth big 0) (nth big 31) (nth big 32) (nth big 1023) (nth big 1024) (nth big 1999))⇒
4109(nth big 500)⇒
500(nth big2 500)⇒
:xfirst
(first [10 20 30])⇒
10(rest [10 20 30])⇒
(quote (20 30))(first nil)⇒
nilrest
(first [10 20 30])⇒
10(rest [10 20 30])⇒
(quote (20 30))(first nil)⇒
nilvector
[]⇒
[][1 2 3]⇒
[1 2 3][[1 2] [3 4]]⇒
[[1 2] [3 4]]hash-map
(hash-map :a 1 :b 2)⇒
{:a 1, :b 2}assoc
(keys (assoc {:z 1, :a 2, :m 3} :a 99))⇒
(quote (:z :a :m))(keys (assoc {:z 1, :a 2} :b 3 :c 4))⇒
(quote (:z :a :b :c))(assoc {:a 1} :b 2)⇒
{:a 1, :b 2}get
(get m 0)⇒
0(get m 100)⇒
1000(get m 199)⇒
1990conj
(clojure.core/deref a)⇒
[1 2 3](conj #{1 2} 3)⇒
#{1 3 2}(conj #{1 2} 2 3)⇒
#{1 3 2}keys
(keys {:z 1, :a 2, :m 3, :b 4})⇒
(quote (:z :a :m :b))(keys (assoc {:z 1, :a 2, :m 3} :a 99))⇒
(quote (:z :a :m))(keys (assoc {:z 1, :a 2} :b 3 :c 4))⇒
(quote (:z :a :b :c))vals
(keys {:a 1, :b 2})⇒
(quote (:a :b))(vals {:a 1, :b 2})⇒
(quote (1 2))hash
(hash 42)⇒
(hash 42)(hash "hello")⇒
(hash "hello")(hash :foo)⇒
(hash :foo)dissoc
(dissoc {:a 1, :b 2, :c 3} :b)⇒
{:a 1, :c 3}(dissoc {:a 1, :b 2, :c 3} :a :c)⇒
{:b 2}(dissoc {:a 1} :z)⇒
{:a 1}Sets
hash-set
(hash-set 1 2 3)⇒
#{1 3 2}contains?
disj
(disj #{1 3 2} 2)⇒
#{1 3}(disj #{1 4 3 2} 2 4)⇒
#{1 3}Atoms
atom
(deref (atom 42))⇒
42(clojure.core/deref (atom 42))⇒
42(clojure.core/deref a)⇒
10deref
(deref (atom 42))⇒
42(clojure.core/deref (atom 42))⇒
42(deref a)⇒
[1 2 3]reset!
atom?
Sequences
reduce
(reduce-kv (fn (acc k v) (assoc acc k (* v 2))) {} {:a 1, :b 2})⇒
{:a 2, :b 4}(reduce + 0 [1 2 3 4 5])⇒
15(reduce + [1 2 3])⇒
6into
(into [] (range 3))⇒
[0 1 2](into #{} [1 2 2 3])⇒
#{1 3 2}(into {} [[:a 1] [:b 2]])⇒
{:a 1, :b 2}apply
(apply + [1 2 3])⇒
6(apply + 1 2 [3 4])⇒
10reverse
(reverse (list 1 2 3))⇒
(quote (3 2 1))(reverse [1 2 3])⇒
(quote (3 2 1))(reverse nil)⇒
nilsort
(sort-by count ["ccc" "a" "bb"])⇒
(quote ("a" "bb" "ccc"))(sort-by count > ["a" "bb" "ccc"])⇒
(quote ("ccc" "bb" "a"))(cond->> [4 3 2 1] true (sort <))⇒
(quote (1 2 3 4))Utility
rand
eval
42⇒
42"hi"⇒
"hi"nil⇒
nilReflection
type
(type (atom 1))⇒
:atom(type (lazy-seq nil))⇒
:lazy-seq(type 42)⇒
:intname
(name :hello)⇒
"hello"(name (quote world))⇒
"world"(name "str")⇒
"str"symbol
(symbol "hello")⇒
(quote hello)(name (symbol "abc"))⇒
"abc"keyword
(keyword "world")⇒
:world(name (keyword "bar"))⇒
"bar"doc
(doc (quote inc-doc__rt))⇒
"increment by one"(doc (quote y__rt))⇒
nil(doc (quote my-id__rt))⇒
"identity macro"source
(car (source (quote sq-src__rt)))⇒
(quote def)apropos
(apropos "zzzznotfound")⇒
nilStrings
str
(when-let (x "hi") (str x "!"))⇒
"hi!"(when-some (x 0) (str "got " x))⇒
"got 0"(str-replace "hello world" " " "-")⇒
"hello-world"pr-str
(pr-str 42)⇒
"42"(pr-str "hi")⇒
"\"hi\""(pr-str 1 :a "b")⇒
"1 :a \"b\""read-string
(eval (read-string "(* 3 4)"))⇒
12(read-string "42")⇒
42(read-string "(+ 1 2)")⇒
(quote (+ 1 2))format
(format "hello %s" "world")⇒
"hello world"(format "n=%d" 42)⇒
"n=42"(format "pi=%f" 3.14)⇒
"pi=3.140000"subs
(subs "hello" 1 3)⇒
"el"(subs "hello" 2)⇒
"llo"split
(split-at 2 [1 2 3 4 5])⇒
[[1 2] [3 4 5]](split-with odd? [1 3 4 2 5])⇒
[[1 3] [4 2 5]](split "a,b,c" ",")⇒
["a" "b" "c"]join
(join "-" ["a" "b" "c"])⇒
"a-b-c"(join ["a" "b" "c"])⇒
"abc"starts-with?
ends-with?
includes?
upper-case
(upper-case "hello")⇒
"HELLO"lower-case
(lower-case "HELLO")⇒
"hello"trim
(trim " hi ")⇒
"hi"(trim "hi")⇒
"hi"char-at
(char-at "hello" 0)⇒
"h"(char-at "hello" 4)⇒
"o"Regex
re-find
(re-find "\\d+" "abc123def")⇒
"123"(re-find "[a-z]+" "123hello456")⇒
"hello"(re-find "xyz" "abc")⇒
nilre-matches
(re-matches "\\d+" "12345")⇒
"12345"(re-matches "\\d+" "123abc")⇒
nil(re-matches "[a-z]+" "hello")⇒
"hello"Type coercion
int
(int 3.7)⇒
3(int 5)⇒
5float
(float 5)⇒
5.0(float 3.14)⇒
3.14Exceptions
throw
(try (+ 1 2) (catch e :fail))⇒
3(try (throw "oops") (catch e (str "caught: " e)))⇒
"caught: oops"(try (throw 42) (catch e (* e 10)))⇒
420Modules
require
Macros
macroexpand-1
(macroexpand-1 (quote (unless__mt x 1 2)))⇒
(quote (if x 2 1))macroexpand
(macroexpand-1 (quote (unless__mt x 1 2)))⇒
(quote (if x 2 1))gensym
Special forms
These forms are recognized directly by the evaluator and cannot be redefined.
quote
(ffirst (quote ((1 2) (3 4))))⇒
1(cons 1 (quote (2 3)))⇒
(quote (1 2 3))(list 1 2 (quote a))⇒
(quote (1 2 a))quasiquote
(my-list__mt 1 2 3)⇒
(quote (1 2 3))unquote
unquote-splicing
def
(+ x__bt 1)⇒
42r__bt⇒
1r__bt⇒
2defmacro
(clojure.core/deref mt-n)⇒
2(doc (quote my-id__rt))⇒
"identity macro"if
(if true 1 2)⇒
1(if false 1 2)⇒
2(if nil 1 2)⇒
2do
(do 1 2 3)⇒
3(do (def d__ct 7) d__ct)⇒
7(run-do 100000)⇒
:donelet
(let (x 5) x)⇒
5(let (x 1 y 2) (+ x y))⇒
3(let (x 1 y (+ x 10)) y)⇒
11fn
(count [1 2 3])⇒
3(count {:a 1, :b 2})⇒
2(count (list 1 2 3))⇒
3loop
(loop (n 5 acc 1) (if (<= n 1) acc (recur (- n 1) (* acc n))))⇒
120(loop (i 0) (if (< i 50000) (recur (+ i 1)) i))⇒
50000(count (loop (i 0 acc []) (if (< i 2000) (recur (+ i 1) (conj acc i)) acc)))⇒
2000recur
(loop (n 5 acc 1) (if (<= n 1) acc (recur (- n 1) (* acc n))))⇒
120(count-down__ft 1000)⇒
"done"(loop (i 0) (if (< i 50000) (recur (+ i 1)) i))⇒
50000try
(try (+ 1 2) (catch e :fail))⇒
3(try (throw "oops") (catch e (str "caught: " e)))⇒
"caught: oops"(try (throw 42) (catch e (* e 10)))⇒
420Standard library
Defined in mino source at startup. View with (source name) at the REPL.
whenmacro
Source
(defmacro when (c & body)
`(if ~c (do ~@body)))(when true 1 2 3)⇒
3(when false :no)⇒
nil(when-not false :ok)⇒
:okcondmacro
Source
(defmacro cond (& clauses)
(if (< (count clauses) 2)
nil
`(if ~(first clauses)
~(first (rest clauses))
(cond ~@(rest (rest clauses))))))(cond false :a true :b)⇒
:b(cond false :a false :b)⇒
nil(cond-> 1 true inc false (* 100) true (* 2))⇒
4andmacro
Source
(defmacro and (& xs)
(if (= 0 (count xs))
true
(if (= 1 (count xs))
(first xs)
(let (g (gensym))
`(let (~g ~(first xs))
(if ~g (and ~@(rest xs)) ~g))))))(and 1 2 3)⇒
3(and 1 false 3)⇒
false(slurp "/tmp/mino_test_spit.txt")⇒
"hello"ormacro
Source
(defmacro or (& xs)
(if (= 0 (count xs))
nil
(if (= 1 (count xs))
(first xs)
(let (g (gensym))
`(let (~g ~(first xs))
(if ~g ~g (or ~@(rest xs))))))))(or nil nil 42)⇒
42(or false false false)⇒
false(and-loop 100000)⇒
true->macro
Source
(defmacro -> (x & forms)
(if (= 0 (count forms))
x
(let (step (first forms))
(if (cons? step)
`(-> (~(first step) ~x ~@(rest step)) ~@(rest forms))
`(-> (~step ~x) ~@(rest forms))))))(-> 10 (- 3) (- 2))⇒
5->>macro
Source
(defmacro ->> (x & forms)
(if (= 0 (count forms))
x
(let (step (first forms))
(if (cons? step)
`(->> (~(first step) ~@(rest step) ~x) ~@(rest forms))
`(->> (~step ~x) ~@(rest forms))))))(->> 10 (- 3) (- 2))⇒
9notfunction
Source
(def not (fn (x) (if x false true)))(if-not false :yes :no)⇒
:yes(if-not true :yes :no)⇒
:no(if-not nil :yes)⇒
:yesnot=function
Source
(def not= (fn (a b) (not (= a b))))identityfunction
Source
(def identity (fn (x) x))a⇒
a(identity 42)⇒
42listfunction
Source
(def list (fn (& args) args))(cons 1 (quote (2 3)))⇒
(quote (1 2 3))(list 1 2 (quote a))⇒
(quote (1 2 a))(car (quote (1 2 3)))⇒
1empty?function
Source
(def empty? (fn (coll) (= (count coll) 0)))>function
Source
(def > (fn (a b & more) (if (< b a) (if (nil? more) true (apply > b more)) false)))(some (fn (x) (> x 10)) [1 2 3])⇒
nil(filter (fn (x) (> x 2)) [1 2 3 4 5])⇒
(quote (3 4 5))<=function
Source
(def <= (fn (a b & more) (if (< b a) false (if (nil? more) true (apply <= b more)))))(loop (n 5 acc 1) (if (<= n 1) acc (recur (- n 1) (* acc n))))⇒
120>=function
Source
(def >= (fn (a b & more) (if (< a b) false (if (nil? more) true (apply >= b more)))))nil?function
Source
(def nil? (fn (x) (= (type x) :nil)))(try (throw nil) (catch e (nil? e)))⇒
truecons?function
Source
(def cons? (fn (x) (= (type x) :list)))string?function
Source
(def string? (fn (x) (= (type x) :string)))number?function
Source
(def number? (fn (x) (let (t (type x)) (or (= t :int) (= t :float)))))(postwalk (fn (x) (if (number? x) (inc x) x)) (quote (1 (2 3))))⇒
(quote (2 (3 4)))keyword?function
Source
(def keyword? (fn (x) (= (type x) :keyword)))symbol?function
Source
(def symbol? (fn (x) (= (type x) :symbol)))vector?function
Source
(def vector? (fn (x) (= (type x) :vector)))map?function
Source
(def map? (fn (x) (= (type x) :map)))fn?function
Source
(def fn? (fn (x) (= (type x) :fn)))set?function
Source
(def set? (fn (x) (= (type x) :set)))swap!function
Source
(def swap! (fn (a f & args) (reset! a (apply f (deref a) args))))defnmacro
Source
(defmacro defn (name params & body)
`(def ~name (fn ~params ~@body)))(inc1__ft 5)⇒
6(f__ft 10)⇒
12mapfunction
Source
(def map (fn (f coll)
(lazy-seq
(let (s (seq coll))
(when s
(cons (f (first s)) (map f (rest s)))))))){}⇒
{}{:a 1, :b 2}⇒
{:a 1, :b 2}{:b 2, :a 1}⇒
{:a 1, :b 2}filterfunction
Source
(def filter (fn (pred coll)
(lazy-seq
(let (s (seq coll))
(when s
(if (pred (first s))
(cons (first s) (filter pred (rest s)))
(filter pred (rest s))))))))(filter (fn (x) (> x 2)) [1 2 3 4 5])⇒
(quote (3 4 5))(filter (fn (x) false) [1 2 3])⇒
niltakefunction
Source
(def take (fn (n coll)
(lazy-seq
(when (> n 0)
(let (s (seq coll))
(when s
(cons (first s) (take (- n 1) (rest s)))))))))(take-last 2 [1 2 3 4 5])⇒
(quote (4 5))(take-last 5 [1 2 3])⇒
(quote (1 2 3))(take 5 (lazy-seq (cons 1 (cons 2 (cons 3 nil)))))⇒
(quote (1 2 3))dropfunction
Source
(def drop (fn (n coll)
(if (<= n 0)
coll
(let (s (seq coll))
(if s
(drop (- n 1) (rest s))
nil)))))(into [] (drop-last [1 2 3 4]))⇒
[1 2 3](into [] (drop-last 2 [1 2 3 4]))⇒
[1 2](drop-while (fn (x) (< x 3)) [1 2 3 4])⇒
(quote (3 4))concatfunction
Source
(def concat (fn (& colls)
(lazy-seq
(when (seq colls)
(let (s (seq (first colls)))
(if s
(cons (first s) (apply concat (cons (rest s) (rest colls))))
(apply concat (rest colls))))))))(concat [1 2] [3 4])⇒
(quote (1 2 3 4))(concat [1] [2] [3])⇒
(quote (1 2 3))(concat [] [1 2])⇒
(quote (1 2))rangefunction
Source
(def range
(let (range-impl (fn (start end step)
(lazy-seq
(when (if (> step 0) (< start end) (> start end))
(cons start (range-impl (+ start step) end step))))))
(fn (& args)
(let (n (count args))
(cond
(= n 1) (range-impl 0 (first args) 1)
(= n 2) (range-impl (first args) (first (rest args)) 1)
(= n 3) (range-impl (first args) (first (rest args)) (first (rest (rest args))))
true nil)))))(into [] (range 3))⇒
[0 1 2](range 5)⇒
(quote (0 1 2 3 4))(range 2 5)⇒
(quote (2 3 4))repeatfunction
Source
(def repeat (fn (n x)
(lazy-seq
(when (> n 0)
(cons x (repeat (- n 1) x))))))(repeat 3 "x")⇒
(quote ("x" "x" "x"))(repeat 0 "x")⇒
nilupdatefunction
Source
(def update (fn (m k f & args)
(assoc m k (apply f (get m k) args))))(update {:a 5} :a (fn (n) (* n 10)))⇒
{:a 50}(get (update ccm__ct :x (fn (n) (+ n 100))) :x)⇒
101(update-in {:a {:b 1}} [:a :b] inc)⇒
{:a {:b 2}}somefunction
Source
(def some (fn (pred coll)
(when (not (empty? coll))
(or (pred (first coll))
(some pred (rest coll))))))(if-some (x false) x :none)⇒
false(if-some (x nil) x :none)⇒
:none(if-some (x 42) x :none)⇒
42every?function
Source
(def every? (fn (pred coll)
(if (empty? coll)
true
(if (pred (first coll))
(every? pred (rest coll))
false))))compfunction
Source
(def comp (fn (f g) (fn (& args) (f (apply g args)))))((comp not nil?) nil)⇒
falsepartialfunction
Source
(def partial (fn (f & bound) (fn (& args) (apply f (concat bound args)))))((partial + 10) 5)⇒
15complementfunction
Source
(def complement (fn (f) (fn (& args) (not (apply f args)))))((complement nil?) 42)⇒
true((complement nil?) nil)⇒
falsesecondfunction
Source
(def second (fn (coll) (first (rest coll))))(second [1 2 3])⇒
2ffirstfunction
Source
(def ffirst (fn (coll) (first (first coll))))(ffirst (quote ((1 2) (3 4))))⇒
1incfunction
Source
(def inc (fn (x) (+ x 1)))(inc 5)⇒
6(postwalk (fn (x) (if (number? x) (inc x) x)) (quote (1 (2 3))))⇒
(quote (2 (3 4)))decfunction
Source
(def dec (fn (x) (- x 1)))(dec 5)⇒
4zero?function
Source
(def zero? (fn (x) (= x 0)))pos?function
Source
(def pos? (fn (x) (> x 0)))neg?function
Source
(def neg? (fn (x) (< x 0)))even?function
Source
(def even? (fn (x) (= (mod x 2) 0)))(into [] (keep (fn (x) (when (even? x) (* x 10))) [1 2 3 4 5]))⇒
[20 40](into [] (keep-indexed (fn (i x) (when (even? i) x)) [:a :b :c :d :e]))⇒
[:a :c :e](into [] (for (x [1 2 3 4 5] :when (even? x)) (* x x)))⇒
[4 16]odd?function
Source
(def odd? (fn (x) (not (even? x))))absfunction
Source
(def abs (fn (x) (if (< x 0) (- x) x)))(abs -5)⇒
5maxfunction
Source
(def max (fn (a b) (if (> a b) a b)))(max 3 7)⇒
7minfunction
Source
(def min (fn (a b) (if (< a b) a b)))(min 3 7)⇒
3not-emptyfunction
Source
(def not-empty (fn (coll) (if (seq coll) coll nil)))(not-empty [1])⇒
[1](not-empty [])⇒
nilconstantlyfunction
Source
(def constantly (fn (x) (fn (& _) x)))((constantly 42) :a :b)⇒
42booleanfunction
Source
(def boolean (fn (x) (if x true false)))(boolean 1)⇒
true(boolean nil)⇒
falseseq?function
Source
(def seq? (fn (x) (or (cons? x) (= (type x) :lazy-seq))))mergefunction
Source
(def merge (fn (& maps)
(reduce (fn (acc m)
(reduce (fn (a kv) (assoc a (first kv) (second kv)))
acc (seq m)))
{} maps)))(merge {:a 1} {:b 2} {:a 3})⇒
{:a 3, :b 2}(merge-with + {:a 1, :b 2} {:a 3, :c 4})⇒
{:a 4, :b 2, :c 4}select-keysfunction
Source
(def select-keys (fn (m ks)
(reduce (fn (acc k)
(if (contains? m k)
(assoc acc k (get m k))
acc))
{} ks)))(select-keys {:a 1, :b 2, :c 3} [:a :c])⇒
{:a 1, :c 3}findfunction
Source
(def find (fn (m k)
(when (contains? m k) (vector k (get m k)))))(find {:a 1, :b 2} :a)⇒
[:a 1](find {:a 1} :z)⇒
nil(re-find "\\d+" "abc123def")⇒
"123"zipmapfunction
Source
(def zipmap
(let (zm-impl (fn (acc ks vs)
(if (and (seq ks) (seq vs))
(zm-impl (assoc acc (first ks) (first vs))
(rest ks) (rest vs))
acc)))
(fn (ks vs) (zm-impl {} ks vs))))(zipmap [:a :b] [1 2])⇒
{:a 1, :b 2}frequenciesfunction
Source
(def frequencies (fn (coll)
(reduce (fn (acc x)
(update acc x (fn (n) (+ (if n n 0) 1))))
{} coll)))(frequencies [1 2 1 3 2 1])⇒
{1 3, 2 2, 3 1}group-byfunction
Source
(def group-by (fn (f coll)
(reduce (fn (acc x)
(let (k (f x))
(update acc k (fn (v) (conj (if v v []) x)))))
{} coll)))(group-by even? [1 2 3 4])⇒
{false [1 3], true [2 4]}juxtfunction
Source
(def juxt (fn (& fs)
(fn (& args) (map (fn (f) (apply f args)) fs))))((juxt inc dec) 5)⇒
(quote (6 4))mapcatfunction
Source
(def mapcat (fn (f coll)
(apply concat (map f coll))))(mapcat (fn (x) [x (* x 10)]) [1 2 3])⇒
(quote (1 10 2 20 3 30))take-whilefunction
Source
(def take-while (fn (pred coll)
(lazy-seq
(let (s (seq coll))
(when (and s (pred (first s)))
(cons (first s) (take-while pred (rest s))))))))(take-while (fn (x) (< x 3)) [1 2 3 4])⇒
(quote (1 2))drop-whilefunction
Source
(def drop-while (fn (pred coll)
(let (s (seq coll))
(if (and s (pred (first s)))
(drop-while pred (rest s))
s))))(drop-while (fn (x) (< x 3)) [1 2 3 4])⇒
(quote (3 4))iteratefunction
Source
(def iterate (fn (f x)
(lazy-seq (cons x (iterate f (f x))))))(take 5 (iterate inc 0))⇒
(quote (0 1 2 3 4))cyclefunction
Source
(def cycle
(let (cycle-impl (fn (orig coll)
(lazy-seq
(let (s (seq coll))
(if s
(cons (first s) (cycle-impl orig (rest s)))
(cycle-impl orig orig))))))
(fn (coll) (cycle-impl coll coll))))(take 5 (cycle [1 2]))⇒
(quote (1 2 1 2 1))repeatedlyfunction
Source
(def repeatedly (fn (f)
(lazy-seq (cons (f) (repeatedly f)))))(take 3 (repeatedly (fn () 42)))⇒
(quote (42 42 42))interleavefunction
Source
(def interleave
(let (interleave-impl (fn (c1 c2)
(lazy-seq
(let (s1 (seq c1) s2 (seq c2))
(when (and s1 s2)
(cons (first s1) (cons (first s2)
(interleave-impl (rest s1) (rest s2)))))))))
(fn (c1 c2) (interleave-impl c1 c2))))(interleave [1 2 3] [:a :b :c])⇒
(quote (1 :a 2 :b 3 :c))interposefunction
Source
(def interpose (fn (sep coll)
(lazy-seq
(let (s (seq coll))
(when s
(cons (first s)
(mapcat (fn (x) (list sep x)) (rest s))))))))(interpose :sep [1 2 3])⇒
(quote (1 :sep 2 :sep 3))distinctfunction
Source
(def distinct
(let (dist-impl (fn (seen coll)
(lazy-seq
(let (s (seq coll))
(when s
(let (x (first s))
(if (contains? seen x)
(dist-impl seen (rest s))
(cons x (dist-impl (conj seen x) (rest s))))))))))
(fn (coll) (dist-impl #{} coll))))(distinct [1 2 1 3 2])⇒
(quote (1 2 3))partitionfunction
Source
(def partition
(let (part-impl (fn (n coll)
(lazy-seq
(let (chunk (into [] (take n coll)))
(when (= (count chunk) n)
(cons chunk (part-impl n (drop n coll))))))))
(fn (n coll) (part-impl n coll))))(into [] (partition-all 3 [1 2 3 4 5 6 7 8]))⇒
[[1 2 3] [4 5 6] [7 8]](partition 2 [1 2 3 4 5 6])⇒
(quote ([1 2] [3 4] [5 6]))partition-byfunction
Source
(def partition-by (fn (f coll)
(lazy-seq
(let (s (seq coll))
(when s
(let (v (f (first s))
run (cons (first s)
(take-while (fn (x) (= (f x) v)) (rest s)))
remaining (drop (count run) s))
(cons run (partition-by f remaining))))))))doallfunction
Source
(def doall (fn (coll)
(let (walk (fn (s) (when (seq s) (walk (rest s)))))
(walk coll)
coll)))(count (doall (map inc [1 2 3])))⇒
3dorunfunction
Source
(def dorun (fn (coll)
(let (walk (fn (s) (when (seq s) (walk (rest s)))))
(walk coll)
nil)))true?function
Source
(def true? (fn (x) (= x true)))false?function
Source
(def false? (fn (x) (= x false)))boolean?function
Source
(def boolean? (fn (x) (or (= x true) (= x false))))int?function
Source
(def int? (fn (x) (= (type x) :int)))float?function
Source
(def float? (fn (x) (= (type x) :float)))some?function
Source
(def some? (fn (x) (not (nil? x))))list?function
Source
(def list? cons?)atom?function
Source
(def atom? (fn (x) (= (type x) :atom)))not-any?function
Source
(def not-any? (fn (pred coll) (not (some pred coll))))not-every?function
Source
(def not-every? (fn (pred coll) (not (every? pred coll))))nextfunction
Source
(def next (fn (coll) (seq (rest coll))))(next [1 2 3])⇒
(quote (2 3))(next [1])⇒
nilnfirstfunction
Source
(def nfirst (fn (coll) (next (first coll))))(nfirst [[1 2] [3 4]])⇒
(quote (2))fnextfunction
Source
(def fnext (fn (coll) (first (next coll))))(fnext [1 3 5])⇒
3nnextfunction
Source
(def nnext (fn (coll) (next (next coll))))(nnext [1 2 3])⇒
(quote (3))(nnext [1 2])⇒
nilkeyfunction
Source
(def key (fn (entry) (first entry)))(key [:a 1])⇒
:a(val [:a 1])⇒
1valfunction
Source
(def val (fn (entry) (second entry)))(key [:a 1])⇒
:a(val [:a 1])⇒
1removefunction
Source
(def remove (fn (pred coll) (filter (complement pred) coll)))(into [] (remove even? [1 2 3 4 5]))⇒
[1 3 5]vecfunction
Source
(def vec (fn (coll) (into [] coll)))(vec (list 1 2 3))⇒
[1 2 3](vec nil)⇒
[](count (loop (i 0 acc []) (if (< i 2000) (recur (+ i 1) (conj acc i)) acc)))⇒
2000rand-intfunction
Source
(def rand-int (fn (n) (int (* (rand) n))))rand-nthfunction
Source
(def rand-nth (fn (coll) (nth coll (rand-int (count coll)))))run!function
Source
(def run! (fn (f coll)
(let (go (fn (s) (when (seq s) (f (first s)) (go (rest s)))))
(go coll)
nil)))if-notmacro
Source
(defmacro if-not (test then & else)
(if (seq else)
`(if (not ~test) ~then ~(first else))
`(if (not ~test) ~then)))(if-not false :yes :no)⇒
:yes(if-not true :yes :no)⇒
:no(if-not nil :yes)⇒
:yeswhen-notmacro
Source
(defmacro when-not (test & body)
`(when (not ~test) ~@body))(when-not false :ok)⇒
:ok(when-not true :ok)⇒
nilif-letmacro
Source
(defmacro if-let (bindings then & else)
(let (sym (first bindings)
expr (first (rest bindings))
g (gensym))
(if (seq else)
`(let (~g ~expr)
(if ~g (let (~sym ~g) ~then) ~(first else)))
`(let (~g ~expr)
(if ~g (let (~sym ~g) ~then))))))(if-let (x 42) x :none)⇒
42(if-let (x nil) x :none)⇒
:none(if-let (x false) x :none)⇒
:nonewhen-letmacro
Source
(defmacro when-let (bindings & body)
(let (sym (first bindings)
expr (first (rest bindings))
g (gensym))
`(let (~g ~expr)
(when ~g (let (~sym ~g) ~@body)))))(when-let (x "hi") (str x "!"))⇒
"hi!"(when-let (x nil) :nope)⇒
nilif-somemacro
Source
(defmacro if-some (bindings then & else)
(let (sym (first bindings)
expr (first (rest bindings))
g (gensym))
(if (seq else)
`(let (~g ~expr)
(if (not (nil? ~g)) (let (~sym ~g) ~then) ~(first else)))
`(let (~g ~expr)
(if (not (nil? ~g)) (let (~sym ~g) ~then))))))(if-some (x false) x :none)⇒
false(if-some (x nil) x :none)⇒
:none(if-some (x 42) x :none)⇒
42when-somemacro
Source
(defmacro when-some (bindings & body)
(let (sym (first bindings)
expr (first (rest bindings))
g (gensym))
`(let (~g ~expr)
(when (not (nil? ~g)) (let (~sym ~g) ~@body)))))(when-some (x 0) (str "got " x))⇒
"got 0"(when-some (x nil) :nope)⇒
nillastfunction
Source
(def last (fn (coll)
(let (s (seq coll))
(if (next s)
(last (next s))
(first s)))))(last [1 2 3])⇒
3(last [1])⇒
1(last nil)⇒
nilbutlastfunction
Source
(def butlast (fn (coll)
(let (s (seq coll))
(when (next s)
(cons (first s) (butlast (next s)))))))(butlast [1 2 3])⇒
(quote (1 2))(butlast [1])⇒
nilnthrestfunction
Source
(def nthrest (fn (coll n)
(if (<= n 0) coll (nthrest (rest coll) (- n 1)))))(into [] (nthrest [1 2 3 4 5] 2))⇒
[3 4 5](into [] (nthrest [1 2] 0))⇒
[1 2]nthnextfunction
Source
(def nthnext (fn (coll n)
(if (<= n 0) (seq coll) (nthnext (next coll) (- n 1)))))(nthnext [1 2 3 4 5] 2)⇒
(quote (3 4 5))(nthnext [1 2] 3)⇒
niltake-lastfunction
Source
(def take-last (fn (n coll)
(let (lead (drop n coll)
step (fn (s lead)
(if (seq lead)
(step (next s) (next lead))
s)))
(step (seq coll) (seq lead)))))(take-last 2 [1 2 3 4 5])⇒
(quote (4 5))(take-last 5 [1 2 3])⇒
(quote (1 2 3))drop-lastfunction
Source
(def drop-last (fn (& args)
(let (n (if (= (count args) 1) 1 (first args))
coll (if (= (count args) 1) (first args) (second args)))
(take (- (count coll) n) coll))))(into [] (drop-last [1 2 3 4]))⇒
[1 2 3](into [] (drop-last 2 [1 2 3 4]))⇒
[1 2]split-atfunction
Source
(def split-at (fn (n coll)
(vector (into [] (take n coll)) (into [] (drop n coll)))))(split-at 2 [1 2 3 4 5])⇒
[[1 2] [3 4 5]]split-withfunction
Source
(def split-with (fn (pred coll)
(vector (into [] (take-while pred coll))
(into [] (drop-while pred coll)))))(split-with odd? [1 3 4 2 5])⇒
[[1 3] [4 2 5]]mapvfunction
Source
(def mapv (fn (f coll) (into [] (map f coll))))(mapv (fn (x) (* x 2)) [1 2 3])⇒
[2 4 6]filtervfunction
Source
(def filterv (fn (pred coll) (into [] (filter pred coll))))(filterv even? [1 2 3 4 5])⇒
[2 4]sort-byfunction
Source
(def sort-by (fn (keyfn & args)
(let (cmp (if (= (count args) 2) (first args) compare)
coll (last args))
(sort (fn (a b) (cmp (keyfn a) (keyfn b))) coll))))(sort-by count ["ccc" "a" "bb"])⇒
(quote ("a" "bb" "ccc"))(sort-by count > ["a" "bb" "ccc"])⇒
(quote ("ccc" "bb" "a"))get-infunction
Source
(def get-in (fn (m ks)
(reduce get m ks)))(get-in {:a {:b 42}} [:a :b])⇒
42(get-in {:a 1} [:b :c])⇒
nilassoc-infunction
Source
(def assoc-in (fn (m ks v)
(let (k (first ks))
(if (next ks)
(assoc m k (assoc-in (get m k) (rest ks) v))
(assoc m k v)))))(assoc-in {} [:a :b] 42)⇒
{:a {:b 42}}(assoc-in {:a {:b 1}} [:a :b] 2)⇒
{:a {:b 2}}update-infunction
Source
(def update-in (fn (m ks f & args)
(let (k (first ks))
(if (next ks)
(assoc m k (apply update-in (get m k) (rest ks) f args))
(assoc m k (apply f (get m k) args))))))(update-in {:a {:b 1}} [:a :b] inc)⇒
{:a {:b 2}}merge-withfunction
Source
(def merge-with (fn (f & maps)
(reduce (fn (acc m)
(reduce (fn (a kv)
(let (k (first kv)
v (second kv))
(if (contains? a k)
(assoc a k (f (get a k) v))
(assoc a k v))))
acc (seq m)))
{} maps)))(merge-with + {:a 1, :b 2} {:a 3, :c 4})⇒
{:a 4, :b 2, :c 4}reduce-kvfunction
Source
(def reduce-kv (fn (f init m)
(reduce (fn (acc kv) (f acc (first kv) (second kv)))
init (seq m))))(reduce-kv (fn (acc k v) (assoc acc k (* v 2))) {} {:a 1, :b 2})⇒
{:a 2, :b 4}replacefunction
Source
(def replace (fn (smap coll)
(map (fn (x) (if (contains? smap x) (get smap x) x)) coll)))(into [] (replace {:a 1, :b 2} [:a :c :b]))⇒
[1 :c 2](str-replace "hello world" " " "-")⇒
"hello-world"(str-replace "a.b.c" "." "")⇒
"abc"str-replacefunction
Source
(def str-replace (fn (s match replacement)
(join replacement (split s match))))(str-replace "hello world" " " "-")⇒
"hello-world"(str-replace "a.b.c" "." "")⇒
"abc"bit-and-notfunction
Source
(def bit-and-not (fn (x y) (bit-and x (bit-not y))))(bit-and-not 7 1)⇒
6bit-testfunction
Source
(def bit-test (fn (x n) (not (= 0 (bit-and x (bit-shift-left 1 n))))))bit-setfunction
Source
(def bit-set (fn (x n) (bit-or x (bit-shift-left 1 n))))(bit-set 0 3)⇒
8bit-clearfunction
Source
(def bit-clear (fn (x n) (bit-and x (bit-not (bit-shift-left 1 n)))))(bit-clear 8 3)⇒
0bit-flipfunction
Source
(def bit-flip (fn (x n) (bit-xor x (bit-shift-left 1 n))))(bit-flip 8 3)⇒
0(bit-flip 0 3)⇒
8blank?function
Source
(def blank? (fn (s)
(or (nil? s) (= (trim s) ""))))comparatorfunction
Source
(def comparator (fn (pred)
(fn (a b) (cond (pred a b) -1 (pred b a) 1 true 0))))((comparator <) 1 2)⇒
-1((comparator <) 2 1)⇒
1((comparator <) 1 1)⇒
0keepfunction
Source
(def keep (fn (f coll)
(lazy-seq
(let (s (seq coll))
(when s
(let (v (f (first s)))
(if (nil? v)
(keep f (rest s))
(cons v (keep f (rest s))))))))))(into [] (keep (fn (x) (when (even? x) (* x 10))) [1 2 3 4 5]))⇒
[20 40](into [] (keep-indexed (fn (i x) (when (even? i) x)) [:a :b :c :d :e]))⇒
[:a :c :e]keep-indexedfunction
Source
(def keep-indexed (fn (f coll)
(let (step (fn (i s)
(lazy-seq
(when (seq s)
(let (v (f i (first s)))
(if (nil? v)
(step (inc i) (rest s))
(cons v (step (inc i) (rest s)))))))))
(step 0 coll))))(into [] (keep-indexed (fn (i x) (when (even? i) x)) [:a :b :c :d :e]))⇒
[:a :c :e]map-indexedfunction
Source
(def map-indexed (fn (f coll)
(let (step (fn (i s)
(lazy-seq
(when (seq s)
(cons (f i (first s))
(step (inc i) (rest s)))))))
(step 0 coll))))(into [] (map-indexed vector [:a :b :c]))⇒
[[0 :a] [1 :b] [2 :c]]partition-allfunction
Source
(def partition-all (fn (n coll)
(lazy-seq
(let (s (seq coll))
(when s
(cons (into [] (take n s))
(partition-all n (drop n s))))))))(into [] (partition-all 3 [1 2 3 4 5 6 7 8]))⇒
[[1 2 3] [4 5 6] [7 8]]reductionsfunction
Source
(def reductions (fn (f & args)
(let (init (if (= (count args) 2) (first args) (first (first args)))
coll (if (= (count args) 2) (second args) (rest (first args)))
step (fn (acc s)
(lazy-seq
(when (seq s)
(let (v (f acc (first s)))
(cons v (step v (rest s))))))))
(cons init (step init coll)))))(into [] (reductions + [1 2 3 4 5]))⇒
[1 3 6 10 15](into [] (reductions + 100 [1 2 3]))⇒
[100 101 103 106]dedupefunction
Source
(def dedupe (fn (coll)
(let (step (fn (prev s)
(lazy-seq
(when (seq s)
(let (x (first s))
(if (= x prev)
(step prev (rest s))
(cons x (step x (rest s)))))))))
(lazy-seq
(when (seq coll)
(cons (first coll) (step (first coll) (rest coll))))))))(into [] (dedupe [1 1 2 3 3 3 4 4 1]))⇒
[1 2 3 4 1]every-predfunction
Source
(def every-pred (fn (& preds)
(fn (& args)
(every? (fn (p) (every? p args)) preds))))some-fnfunction
Source
(def some-fn (fn (& preds)
(fn (& args)
(some (fn (p) (some p args)) preds))))fnilfunction
Source
(def fnil (fn (f default)
(fn (& args)
(apply f (cons (if (nil? (first args)) default (first args))
(rest args))))))((fnil + 0) nil 5)⇒
5((fnil + 0) 3 4)⇒
7memoizefunction
Source
(def memoize (fn (f)
(let (cache (atom {}))
(fn (& args)
(let (key args
hit (get (deref cache) key))
(if (not (nil? hit))
hit
(let (v (apply f args))
(swap! cache assoc key v)
v)))))))(f 3)⇒
9(f 3)⇒
9(deref call-count)⇒
1trampolinefunction
Source
(def trampoline (fn (f & args)
(let (result (apply f args)
bounce (fn (r) (if (fn? r) (bounce (r)) r)))
(bounce result))))(trampoline my-bounce 1000)⇒
:doneas->macro
Source
(defmacro as-> (expr sym & forms)
(if (= 0 (count forms))
expr
`(let (~sym ~expr)
(as-> ~(first forms) ~sym ~@(rest forms)))))(as-> 1 x (+ x 2) (* x 3))⇒
9cond->macro
Source
(defmacro cond-> (expr & clauses)
(if (< (count clauses) 2)
expr
(let (g (gensym)
test (first clauses)
step (first (rest clauses)))
`(let (~g ~expr)
(cond-> (if ~test
~(if (cons? step)
`(~(first step) ~g ~@(rest step))
`(~step ~g))
~g)
~@(rest (rest clauses)))))))(cond-> 1 true inc false (* 100) true (* 2))⇒
4cond->>macro
Source
(defmacro cond->> (expr & clauses)
(if (< (count clauses) 2)
expr
(let (g (gensym)
test (first clauses)
step (first (rest clauses)))
`(let (~g ~expr)
(cond->> (if ~test
~(if (cons? step)
`(~(first step) ~@(rest step) ~g)
`(~step ~g))
~g)
~@(rest (rest clauses)))))))(cond->> [4 3 2 1] true (sort <))⇒
(quote (1 2 3 4))dotomacro
Source
(defmacro doto (x & forms)
(let (g (gensym)
stmts (apply list (map (fn (f) (if (cons? f)
`(~(first f) ~g ~@(rest f))
`(~f ~g)))
forms)))
`(let (~g ~x)
~@stmts
~g)))(deref a)⇒
[1 2]dotimesmacro
Source
(defmacro dotimes (bindings & body)
(let (sym (first bindings)
n (first (rest bindings))
gn (gensym)
go (gensym))
`(let (~gn ~n
~go (fn (~sym)
(when (< ~sym ~gn)
~@body
(~go (inc ~sym)))))
(~go 0))))(deref a)⇒
[0 1 2 3 4]doseqmacro
Source
(defmacro doseq (bindings & body)
(let (sym (first bindings)
coll (first (rest bindings))
gs (gensym)
go (gensym))
`(let (~go (fn (~gs)
(when ~gs
(let (~sym (first ~gs))
~@body
(~go (next ~gs))))))
(~go (seq ~coll)))))(deref a)⇒
[20 40 60]shufflefunction
Source
(def shuffle (fn (coll)
(let (v (vec coll)
n (count v)
step (fn (v i)
(if (= i 0)
v
(let (j (rand-int (inc i)))
(step (assoc (assoc v i (nth v j)) j (nth v i))
(dec i))))))
(into [] (step v (dec n))))))(count v)⇒
5(into #{} v)⇒
#{1 4 3 2 5}timemacro
Source
(defmacro time (& body)
(let (start (gensym)
result (gensym))
`(let (~start (time-ms)
~result (do ~@body))
(println (str "Elapsed time: " (- (time-ms) ~start) " ms"))
~result)))flattenfunction
Source
(def flatten (fn (coll)
(lazy-seq
(let (s (seq coll))
(when s
(let (x (first s))
(if (or (cons? x) (vector? x) (seq? x))
(concat (flatten x) (flatten (rest s)))
(cons x (flatten (rest s))))))))))(into [] (flatten [[1 2] [3 [4 5]] 6]))⇒
[1 2 3 4 5 6](into [] (flatten [1 2 3]))⇒
[1 2 3]tree-seqfunction
Source
(def tree-seq (fn (branch? children root)
(let (walk (fn (node)
(lazy-seq
(cons node
(when (branch? node)
(mapcat walk (children node)))))))
(walk root))))(into [] (tree-seq vector? seq [1 [2 [3]]]))⇒
[[1 [2 [3]]] 1 [2 [3]] 2 [3] 3]walkfunction
Source
(def walk (fn (inner outer form)
(cond
(cons? form) (outer (apply list (map inner form)))
(vector? form) (outer (mapv inner form))
(map? form) (outer (into {} (map inner (seq form))))
(set? form) (outer (into #{} (map inner form)))
true (outer form))))(postwalk (fn (x) (if (number? x) (inc x) x)) (quote (1 (2 3))))⇒
(quote (2 (3 4)))(postwalk-replace {:a 1, :b 2} [:a [:b :c]])⇒
[1 [2 :c]](prewalk-replace {:a 1, :b 2} [:a [:b :c]])⇒
[1 [2 :c]]postwalkfunction
Source
(def postwalk (fn (f form) (walk (fn (x) (postwalk f x)) f form)))(postwalk (fn (x) (if (number? x) (inc x) x)) (quote (1 (2 3))))⇒
(quote (2 (3 4)))prewalkfunction
Source
(def prewalk (fn (f form) (walk (fn (x) (prewalk f x)) identity (f form))))postwalk-replacefunction
Source
(def postwalk-replace (fn (smap form)
(postwalk (fn (x) (if (contains? smap x) (get smap x) x)) form)))(postwalk-replace {:a 1, :b 2} [:a [:b :c]])⇒
[1 [2 :c]]prewalk-replacefunction
Source
(def prewalk-replace (fn (smap form)
(prewalk (fn (x) (if (contains? smap x) (get smap x) x)) form)))(prewalk-replace {:a 1, :b 2} [:a [:b :c]])⇒
[1 [2 :c]]re-seqfunction
Source
(def re-seq
(let (find-index (fn (s sub i)
(if (> (+ i (count sub)) (count s))
nil
(if (= (subs s i (+ i (count sub))) sub)
i
(find-index s sub (inc i))))))
(fn (pattern s)
(lazy-seq
(when-let (m (re-find pattern s))
(let (idx (find-index s m 0))
(when (not (nil? idx))
(let (rest-s (subs s (+ idx (max (count m) 1))))
(cons m (re-seq pattern rest-s))))))))))(into [] (re-seq "\\d+" "abc123def456ghi"))⇒
["123" "456"](into [] (re-seq "[a-z]" "a1b2c3"))⇒
["a" "b" "c"]condpmacro
Source
(defmacro condp (pred expr & clauses)
(let (gexpr (gensym))
`(let (~gexpr ~expr)
~(let (build (fn (cls)
(if (< (count cls) 2)
(if (= (count cls) 1)
(first cls)
nil)
(let (test (first cls)
then (first (rest cls))
more (rest (rest cls)))
`(if (~pred ~test ~gexpr)
~then
~(build more))))))
(build clauses)))))(condp = 2 1 "one" 2 "two" 3 "three")⇒
"two"(condp = 99 1 "one" "default")⇒
"default"casemacro
Source
(defmacro case (expr & clauses)
(let (gexpr (gensym))
`(let (~gexpr ~expr)
~(let (build (fn (cls)
(if (< (count cls) 2)
(if (= (count cls) 1)
(first cls)
nil)
`(if (= ~gexpr ~(first cls))
~(first (rest cls))
~(build (rest (rest cls)))))))
(build clauses)))))(case :b :a 1 :b 2 :c 3)⇒
2(case :z :a 1 :default)⇒
:default(upper-case "hello")⇒
"HELLO"formacro
Source
(defmacro for (bindings & body)
(let (sym (first bindings)
coll (first (rest bindings))
opts (rest (rest bindings))
when-clause (when (and (seq opts) (= (first opts) :when))
(first (rest opts))))
(if when-clause
`(map (fn (~sym) ~@body)
(filter (fn (~sym) ~when-clause) ~coll))
`(map (fn (~sym) ~@body) ~coll))))(into [] (for (x [1 2 3 4 5]) (* x x)))⇒
[1 4 9 16 25](into [] (for (x [1 2 3 4 5] :when (even? x)) (* x x)))⇒
[4 16]I/O primitives
Available only after the host calls mino_install_io(). Not present in sandboxed environments.
println
(println "io-test-println")⇒
nilprn
(prn 1 2 3)⇒
nilslurp
(slurp "/tmp/mino_test_spit.txt")⇒
"hello"(slurp "/tmp/mino_test_spit2.txt")⇒
"42"spit
(slurp "/tmp/mino_test_spit.txt")⇒
"hello"(slurp "/tmp/mino_test_spit2.txt")⇒
"42"