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
(defn rec-find [pred x] | |
(cond | |
(pred x) true | |
(sequential? x) (some #(rec-find pred %) | |
x) | |
(map? x) (some #(rec-find pred %) | |
(vals x)))) |
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
(defn fullhouse3 [hand] | |
(let [index (->> hand | |
(group-by :rank) | |
vals | |
(sort-by (fn [same] [(count same) | |
(:rank (first same))] | |
>))) | |
[fst snd] index] | |
(when (and (= (count fst) 3) | |
(>= (count snd) 2)) |
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
(defun clojurescript-repl () | |
(interactive) | |
(run-lisp "lein1 trampoline cljsbuild repl-listen") | |
(paredit-mode +1)) |
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
(defn replace-pred-once [pred replacement list] | |
(let [[bef | |
[elt & aft]] (split-with (complement pred) | |
list)] | |
(concat bef [replacement] aft))) | |
(comment (replace-pred-once #{5} :foo [1 2 3 4 5 6 7 8 5 3]) | |
=> (1 2 3 4 :foo 6 7 8 5 3) |
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
(extend-type js/Function | |
IPrintWithWriter | |
(-pr-writer [a writer opts] | |
(-write writer "#<Fn>"))) | |
;; will give a warning, but work... |
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
;; no assumtion of outer state/events | |
;; more setup work, more flexibility and straightforward testing | |
(defn my-component [model event-channel] | |
[:div.blah | |
(for [blub @model] | |
[:div.blub {:on-click #(>! event-channel [:blub-click (:id blub)])} | |
(:text blub)])]) | |
;; uses global app-state and global event-queue |
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
(def weak-minor-5 | |
[:and | |
[:length-range 9] | |
:minor | |
[:gcp-range 0 14]]) | |
(def weak-major-4 | |
[:and | |
[:length-range 8] | |
:major |
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 tools.blitz-test | |
(:require [cljs.test :refer-macros [is testing]] | |
[devcards.core :refer-macros [defcard-rg deftest]] | |
[clojure.string :as str])) | |
(def group-a | |
{:players [["Lena" 1 "Trix"] | |
["Klaus" 1 "GoKlaus"] | |
["Christoph" 2 "Coreon"] | |
["Martin" 2 "LDD99"] |