Files
rust-mal/core/core.mal
2024-01-17 20:58:25 +09:00

37 lines
603 B
Plaintext

;; Previously in core.rs
; Logic
(def! not (fn* [x]
(if x nil true)))
(def! and (fn* [a b]
(if a
b)))
(def! or (fn* [a b]
(if a
true
b)))
(def! xor (fn* [a b]
(if a
(not b)
b)))
; Other functions in core.rs
(def! assert-eq (fn* [a b]
(assert (= a b))))
(def! empty? (fn* [l]
(= (count l) 0)))
;; File-interaction functions
(def! load-file (fn* [f]
(eval (read-string (str "(do\n" (slurp f) "\nnil)")))))
(def! conf-reload (fn* []
(load-file (str MAL_HOME "/" "config.mal"))))
;; Shorthand
(def! quit (fn* []
(exit 0)))