Skip to content

Instantly share code, notes, and snippets.

@rotaliator
rotaliator / app.cljs
Last active February 20, 2019 09:19
Minimal shadow-cljs app
(ns example.app
(:require [reagent.core :as reagent :refer [atom]]))
(defn app []
[:div
[:h1 "Shadow cljs!"]])
(defn mount-root []
(reagent/render [app] (.getElementById js/document "app")))
def _get_class(class_name):
parts = class_name.split(".")
module = ".".join(parts[:-1])
m = __import__(module)
for comp in parts[1:]:
m = getattr(m, comp)
return m
(defn separate-by [f coll]
"Separates coll into two groups by predicate f
example:
=> (separate-by odd? (range 20))
[[1 3 5 7 9 11 13 15 17 19] [0 2 4 6 8 10 12 14 16 18]]
"
(let [groups (group-by (comp boolean f) coll)]
[(groups true) (groups false)]))
;; or