application/octet-stream
•
864 B
•
26 lines
;; Nujel - Copyright (C) 2020-2021 - Benjamin Vincent Schulenburg
;; This project uses the MIT license, a copy should be included under /LICENSE
;;
;; Mostly macros for all kinds of let varieties
[defn let/arg [arg]
[when arg
[when [or [not [pair? arg]]
[not [symbol? [car arg]]]]
[throw [list :invalid-let-form "Please fix the structure of the let form" arg]]]
`[def ~[car arg] ~[cadr arg]]]]
[defn let/args [args]
[if-not args #nil
[cons [let/arg [car args]]
[let/args [cdr args]]]]]
[defmacro let [bindings . body]
"Evalutes to BODY if PRED is true"
`[let* [do ~@[let/args bindings] ~@body]]]
[defmacro if-let [binding then else]
`[let* [def ~[car binding] ~[cadr binding]]
[if ~[car binding] ~then ~else]]]
[defmacro when-let [binding . body]
`[if-let ~binding ~[cons 'do body] #nil]]