Skip to content

Instantly share code, notes, and snippets.

@gdanov
gdanov / .gitignore
Last active December 16, 2018 17:27
Javascript's OO explained
javascript_oo.html
{"field":"value"}
@gdanov
gdanov / expr-collp.clj
Last active June 14, 2016 09:06
expression / collection predicate map
(deftest coll-preds-test
(let [preds ['coll? 'vector? 'map? 'list? 'seq? 'seqable? 'sequential?]
exprs {"01 \"string\"" "string"
"02 []" []
"03 {}" {}
"04 '(number? 1)" '(number? 1)
"05 `(number? 1)" `(number? 1)
"06 `#(identity %)" `#(identity %)
"07 '#(identity %)" '#(identity %)
"08 `(fn [])" `(fn [])
(ns core
(:require [clojure.spec :as sp]))
(sp/def ::backslash #(= % \\))
(sp/def ::quote #(= % \"))
;; \" ... \\ \" is invalid string *body* and it's better to
;; aggressively terminate as early as possible there is more than one
;; way to define (resp. catch) (in)valid string!