Skip to content

Instantly share code, notes, and snippets.

freeVars :: Exp -> [Id]
freeVars = nub . go [] where
go env (Var v) | v `elem` env = []
| otherwise = [v]
go _ (Nat _) = []
go _ (Op _) = []
go env (Lam arg body) = go (arg:env) body
go env (App f x) = go env f ++ go env x
The floor.
The floor.
A cloud of ghostly flame.
The memory of flames past. Neither resistance to fire nor negative energy
protect against these clouds; only armour will suffice. Luckily, standing in
them causes very little harm. The spectres that emerge from the flames, on the
==> cdh-master: Running provisioner: shell...
cdh-master: Running: inline script
==> cdh-master: stdin: is not a tty
==> cdh-master: Exception in thread "main"
==> cdh-master: java.lang.NoClassDefFoundError: com/factual/hbase/HBaseUtil
==> cdh-master: at com.factual.snapshots.server.SetupSnapshotTable.main(SetupSnapshotTable.java:8)
==> cdh-master: Caused by: java.lang.ClassNotFoundException: com.factual.hbase.HBaseUtil
==> cdh-master: at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
==> cdh-master: at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
==> cdh-master: at java.security.AccessController.doPrivileged(Native Method)
@amalloy
amalloy / parens.clj
Last active August 29, 2015 14:13 — forked from djtrack16/parens.clj
(fn [o]
(set
((fn q [s o c]
(apply concat
(let [a (when (pos? o)
(q (concat s "(") (dec o) (inc c)))
b (when (pos? c)
(q (concat s ")") o (dec c)))]
(if (and (zero? o) (zero? c))
[[(clojure.string/join s)]]
^@^@^@^@^@^@^@^@^@^@^G^MDᾫ^@^@^@^@^@^@^@^@^F<FF>^K^@^A^@^@^@$2d6d133e-c995-4175-
a357-130f83cc63cd^L^@^B^K^@^C^@^@^@^Fsevad^@^D^@^@^@
^O^@^E^K^@^@^@^@^L^@^F^L^@^A^L^@^A^L^@^B^K^@^A^@^@^@$005ee71f-32a3-4871-a2a9-ca3
0e0122fe1^K^@^B^@^@^@ a54b567727788e66547ecea57e36012e^K^@^C^@^@^@^Fa26Kfg
^@^E^@^@^A:F<F1>-<F0>^H^@^F^@^@^@^^^L^@^G^H^@^B^@^@^A<F4>^H^@^C^@^@^Ex^K^@^G^@^@
^@+http://www.kudzu.com/m/Saddle-Peak-13398302^K^@ ^@^@^@'ExtendedAttribute
sExtraction_2012_10_09^M^@^L^K^K^@^@^@^D^@^@^@^F_ds_id^@^@^@^B76^@^@^@^Lsc_rules
_sha^@^@^@(f514ee8060c10343182945167a6e77d03b472592^@^@^@^F_rs_id^@^@^@^C796^@^@^@^E_rs_v^@^@^@
134568822^@^M^@^@^@^T^K^@^O^@^@^@^FeTrXvg^@^K^@^H^@^@^A<FA>{"region":"GA","multi_category_ids":["292"],"og_address":"1299 Ocean Ave","status":"1","melissa_address_key":"30303000000","rbdi":"U","tel":"(310) 656-7600","address_accuracy":"AE02;AE07","postcode":"30303","_original_category":"mapped: Property Management","category_ids":["292"],"country":"us","rawaddress":"1299 Ocean Ave","category"
def categorize(fn, coll):
"""Like group_by, but fn returns multiple keys"""
acc = {}
for e in coll:
for key in fn(e):
acc.setdefault(key, []).append(e)
return acc
def group_by(fn, l):
(reduce (fn [mentioned-files file]
(if (some #{file} mentioned-files)
mentioned-files
(let [duplicates (duplicates-of-file file files (:precision options))]
(when (seq duplicates)
(printf "%s\n" file)
(doseq [d duplicates]
(printf "%s\n" d))
(printf "\n"))
(concat mentioned-files duplicates))))
(defmacro as->
"Binds name to expr, evaluates the first form in the lexical context
of that binding, then binds name to that result, repeating for each
successive form, returning the result of the last form."
{:added "1.5"}
[expr name & forms]
`(let [~name ~expr
~@(interleave (repeat name) (butlast forms))]
~(last forms)))
(ns cljclass)
;; Various ways to solve the problem of transforming a vector to a vector of indices starting at zero, but
;; using an index of -1 for items for which (pred item) is true.
;; E.g. (index-except odd? [1 4 18 7 9 2 4 3]) => [-1 0 1 -1 -1 2 3 -1]
;; NB:
;; This is not the same as assigning indices and replacing the elements for which pred is true with -1.
;; E.g. (index-except odd? [1 2 3]) => [-1 0 -1] and not [-1 1 -1].
(defn permx [coll]
(letfn [(helper [m]
(if (empty? m)
'(())
(for [[i x] m
perm (helper (dissoc m i))]
(cons x perm))))]
(helper (into (sorted-map)
(map-indexed vector coll)))))