mirror of
https://github.com/teo3300/rust-mal.git
synced 2026-01-12 01:05:32 +01:00
- Collect function as fn:(collector, x) -> new_collector for collections - Moving some definitions to "libs" folder - Map and filter defined in mal
24 lines
370 B
Plaintext
24 lines
370 B
Plaintext
(def! abs (fn* [a]
|
|
(if (> a 0)
|
|
a
|
|
(- 0 a))))
|
|
|
|
(def! mod (fn* [a b]
|
|
(- a (* (/ a b) b))))
|
|
|
|
(def! max (fn* [a b]
|
|
(if (> a b)
|
|
a
|
|
b)))
|
|
|
|
(def! min (fn* [a b]
|
|
(if (< a b)
|
|
a
|
|
b)))
|
|
|
|
(def! fact (fn* [a]
|
|
(def! fact-r (fn* [a b]
|
|
(if (not (> a 1)) b
|
|
(fact-r (- a 1) (* a b)))))
|
|
(fact-r a 1)))
|