mirror of
https://github.com/teo3300/rust-mal.git
synced 2026-01-13 09:35:32 +01:00
37 lines
603 B
Plaintext
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)))
|