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
{:paths ["."] | |
:deps {org.clojure/math.combinatorics {:mvn/version "0.1.4"}}} |
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
{"white" #{"anti-flash" "antique" "beige" "blond" "cornsilk" "cosmic latte" "cream" "eggshell" | |
"floral" "ghost" "honeydew" "isabelline" "ivory" "lavender blush" "lemon chiffon" | |
"linen" "magnolia" "mint cream" "navajo" "old lace" "papaya whip" "peach" "pearl" | |
"seashell" "snow" "splashed" "vanilla" "white" "smoke"} | |
"yellow" #{"amber" "apricot" "arylide" "aureolin" "beige" "buff" "chartreuse" "citrine" "cream" | |
"dark goldenrod" "ecru" "flax" "gold" "gold (metallic)" "goldenrod" "harvest gold" | |
"jasmine" "jonquil" "khaki" "lemon chiffon" "lion" "maize" "mikado" "mustard" "naples" | |
"navajo white" "old gold" "olive" "papaya whip" "saffron" "school bus" "selective" | |
"stil de grain" "straw" "sunglow" "vanilla" "yellow"} | |
"gray" #{"ash" "battleship" "black" "blue-gray" "cadet" "charcoal" "cool" "davy's" "gray" |
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 collify [x-or-coll] | |
(if (coll? x-or-coll) | |
x-or-coll | |
[x-or-coll])) | |
(defn keyword->symbol [k] | |
(symbol (name k))) | |
(defmacro expand-set-values | |
[attributes] |
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 sof.async | |
(:require [ring.adapter.jetty :as jetty] | |
[clj-http.client :as client] | |
[ring.middleware.json :refer [wrap-json-response]] | |
[ring.util.response :refer [response]])) | |
(defn handler [request respond raise] | |
(client/get "http://example.com" | |
{:async? true} | |
(fn [response] (respond {:body "something"})) |
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 clojure-playground.tap.model) | |
(def empty-board | |
[[:_ :_ :_] | |
[:_ :_ :_] | |
[:_ :_ :_]]) | |
(def win-patterns | |
[[[0 0] [1 0] [2 0]] | |
[[0 1] [1 1] [2 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
; :dependencies [[hickory "0.7.1"]] | |
(require '[clojure.pprint :refer [print-table]] | |
'[clojure.string :as string] | |
'[hickory.core :refer [as-hickory parse]] | |
'[hickory.select :as s]) | |
(def choices #{"1 2 3" "2 3 1" "3 1 2" "1 3 2" "3 2 1" "2 1 3"}) | |
(def meanings |
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 indent-tree.core | |
(:require [clojure.string :as string])) | |
(defn resolve-insert-path [full-tree level] | |
(:path | |
(reduce (fn [{:keys [path tree] :as current} n] | |
(let [after-last-child-pos (count (second tree))] | |
(if (= n 1) | |
(-> current | |
(update :path into [1 after-last-child-pos]) |
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 notebook.core | |
(:require [clj-http.client :as http] | |
[clojure.data.json :as json] | |
[clojure.string :as string])) | |
(set! *print-length* -1) | |
(def notebooks (json/read-str (:body (http/get "https://notebookspec.com/api/notebook")) | |
:key-fn keyword)) |
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 codebattle101 | |
(:require [clojure.math.combinatorics :as math])) | |
(defn find-better [target best [a b] input-list] | |
(let [ab (* a b)] | |
(loop [[current-min-diff :as current-best] best | |
l 0 | |
r (count input-list)] | |
(let [pos (quot (+ l r) 2) | |
c (get input-list pos) |
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 condp-> | |
"Takes an expression and a set of predicate/form pairs. Threads expr (via ->) | |
through each form for which the corresponding predicate is true of expr. | |
Note that, unlike cond branching, condp-> threading does not short circuit | |
after the first true test expression." | |
[expr & clauses] | |
(assert (even? (count clauses))) | |
(let [g (gensym) | |
pstep (fn [[pred step]] `(if (~pred ~g) (-> ~g ~step) ~g))] | |
`(let [~g ~expr |