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:
parent
017c18112c
commit
9bb30b9863
1 changed files with 11 additions and 0 deletions
|
@ -27,6 +27,17 @@
|
||||||
res#
|
res#
|
||||||
~else)))
|
~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=
|
(defmacro ret=
|
||||||
"compares two values using [=]. If the result is true
|
"compares two values using [=]. If the result is true
|
||||||
returns the value, else the result of [=].
|
returns the value, else the result of [=].
|
||||||
|
|
Loading…
Reference in a new issue