Skip to content

Instantly share code, notes, and snippets.

View rafd's full-sized avatar
🐃
yak-shaving

Rafal Dittwald rafd

🐃
yak-shaving
View GitHub Profile
@rafd
rafd / tic-tac-toe.cljs
Created October 6, 2022 01:06
clojodojo-2022-10-05-tic-tac-toe
(ns demo.ui
(:require
[reagent.core :as r]))
(defonce state (r/atom {:game-board [[:x :o :x] [:o nil nil] [nil nil nil]]
:current-player :x}))
;; "how can i represent any moment of my app as a dictionary"
(defn flip0 [player]
(if (= player :x)
@rafd
rafd / core.clj
Created December 8, 2022 02:17
2022-12-07 clojure workshop leaky bucket
(ns demo.core)
;; inputs are "litres/s"
;; bucket is leaking 1 l/s
;; bucket has capacity of 10
;; does the input overflow the bucket?
(defn leaky-bucket-overflowing?
[limit list]
(->> list
@rafd
rafd / probability.clj
Created February 2, 2023 01:18
2023-02-01 clojure meetup
;; 2 blue balls, 6 yellow balls
;; opt a - take 3, win if there are not 2 blue
;; opt b - take 1, win if it isn't blue
;; which option better?
;;(def bag {:blueballs #{'x 'y} :yellow-balls #{'a 'b 'c 'd 'e 'f}})
;;(def bag [1 1 0 0 0 0 0 0])
(def prototype-bag