Skip to content

Instantly share code, notes, and snippets.

(defn roll-fate-die []
(- (rand-int 3) 1))
(defn test-fate-percentages [rolls-count]
(let [rolls (map (fn [x]
(reduce + (map (fn [x] (roll-fate-die))
(range 4))))
(range rolls-count))]
(map (fn [x] [(first x)
(int (* 100 (/ (count (second x)) rolls-count)))])
(let [x ‘(1 2 (3 4))]
`(+ 8 ~@x))
;; => (clojure.core/+ 8 1 2 (3 4))
`(defmacro ~macro-name [x# y#]
`(if (> ~~num (rand-int 100)) ~x# ~y#))))
~@(map (fn [num] (...))
(range 100))
(list ‘a ‘b ‘c)
;;=> (a b c)
(= a a)
;; => java.lang.Exception: Unable to resolve symbol: a in this context
(= ‘a ‘a)
;;=> true
`(list ~@(map (fn [num]
(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__))
(let [macro-name (symbol (str "if" num))]