Experimental when-else2 macro added, needs testing when I get online

It seems to be working but I forgot everything about macros already lol
This commit is contained in:
Felisp 2024-01-05 14:14:47 +01:00
parent 017c18112c
commit 9bb30b9863

View file

@ -27,6 +27,17 @@
res#
~else)))
;; Todo: Test this properly and if working, replace when-else with this
;; Todo: find a way to download clojure documentation for offline use
(defmacro when-else2
"Evaluates [tst], if it's truthy value returns that value.
If it's not, execute everything in [else] and return last expr."
[tst & else]
`(let [res# ~tst]
(if res#
res#
(do ~@else))))
(defmacro ret=
"compares two values using [=]. If the result is true
returns the value, else the result of [=].