Skip to content

Commit 4551b92

Browse files
committed
std: Add if? if-not? when? when-not? truey fns
1 parent ec3421c commit 4551b92

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

core/src/ys/std.clj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,18 @@
723723

724724
(defmacro &&& [x & xs] `(and? ~x ~@xs))
725725

726+
(defn if? [cond then else]
727+
(if (truey? cond) then else))
728+
729+
(defn if-not? [cond then else]
730+
(if-not (truey? cond) then else))
731+
732+
(defn when? [cond & body]
733+
(when (truey? cond) (doall body)))
734+
735+
(defn when-not? [cond & body]
736+
(when (falsey? cond) (doall body)))
737+
726738

727739
;;------------------------------------------------------------------------------
728740
;; File system functions

0 commit comments

Comments
 (0)