This file contains hidden or 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
package com.example; | |
import static java.util.Collections.*; | |
import java.util.Collection; | |
import java.util.HashMap; | |
import java.util.Map; | |
import java.util.Set; | |
import java.util.concurrent.TimeUnit; |
This file contains hidden or 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 t | |
"trie containing the 100,000 most common english words" | |
(with-open [r (clojure.java.io/reader "/tmp/words-100000")] | |
(reduce #(assoc-in %1 %2 (sorted-map \0 nil)) (sorted-map) (line-seq r)))) | |
(defn search [p m] | |
"return a sorted sequence of all words in the trie m that start with the given prefix p" | |
(let [n (get-in m p) | |
next (mapcat #(search (str p (key %)) m) (dissoc n \0))] | |
(if (contains? n \0) (cons p next) next))) |
This file contains hidden or 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 sokoban.core) | |
(comment #{:n :s :e :w}) | |
(def start-world | |
{:person [3 1] | |
:targets #{[1 3]} | |
:crates #{[1 2]} | |
:blanks #{[1 3] [2 3] [3 3] | |
[1 2] [3 2] |
This file contains hidden or 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 brisfunctional-zipper.core) | |
(def sample | |
[:+ [:* 5 6] [:* 7 4] [:+ 1 2]]) | |
(defn loc [l r c p] | |
{:left l | |
:right r | |
:cur c | |
:path p}) |
This file contains hidden or 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
#!/bin/bash | |
for f in $(egrep -o -R "defn?-? [^ ]*" * --include '*.clj' | cut -d \ -f 2 | sort | uniq); do | |
echo $f $(grep -R --include '*.clj' -- "$f" * | wc -l); | |
done | grep " 1$" |
NewerOlder