Last active
April 4, 2024 16:18
-
-
Save piranha/41856a8dbc0ca43c3a7af7e2e1b05c0b to your computer and use it in GitHub Desktop.
cond+
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro cond+ [& clauses] | |
(when-some [[test expr & rest] clauses] | |
(condp = test | |
:do `(do ~expr (cond+ ~@rest)) | |
:let `(let ~expr (cond+ ~@rest)) | |
:some `(or ~expr (cond+ ~@rest)) | |
`(if ~test ~expr (cond+ ~@rest))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns example | |
(:require [cond+ :refer [cond+]]) | |
(cond+ | |
(= a b) :true | |
:do (prn a) | |
:some b | |
:let [b a] | |
(= a b) :finally) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment