Skip to content

Instantly share code, notes, and snippets.

;; nothing gets evaluated inside the list at all..
‘(a b c)
;;before compilation
(defmacro ifWorkday [bigCalc1, bigCalc2]
`(if (workday (today))
~bigCalc1
~bigCalc2))
;; the call
(ifWorkday (+ 1 1) (otherBigCalc))
;;... after compilation...
(if25 (doFirst) (doSecond))
(defmacro make-percents []
`(list ~@(map (fn [num]
(let [macro-name (symbol (str "if" num))]
`(defmacro ~macro-name [x# y#]
`(if (> ~~num (rand-int 100)) ~x# ~y#))))
(range 100))))
(make-percents)
(defmacro if0 [x__2603__auto__ y__2604__auto__] `(if (> 0 (rand-int 100)) ~x__2603__auto__ ~y__2604__auto__))
(defmacro if1 [x__2604__auto__ y__2605__auto__] `(if (> 1 (rand-int 100)) ~x__2604__auto__ ~y__2605__auto__))
(defmacro if2 [x__2606__auto__ y__2607__auto__] `(if (> 2 (rand-int 100)) ~x__2606__auto__ ~y__2607__auto__))
...
(defmacro if99 [x__2609__auto__ y__2601__auto__] `(if (> 99 (rand-int 100)) ~x__2609__auto__ ~y__2601__auto__))
`(list ~@(map (fn [num]
(let [macro-name (symbol (str "if" num))]
`(defmacro ~macro-name [x# y#]
`(if (> ~~num (rand-int 100)) ~x# ~y#))))
(let [x ‘(1 2 (3 4))]
`(+ 8 ~@x))
;; => (clojure.core/+ 8 1 2 (3 4))
(list ‘a ‘b ‘c)
;;=> (a b c)