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
(defn update-the-submap [m word] | |
(update-in m [word] (fnil inc 0))) | |
(defn update-the-map [m triplet] | |
(let [thekey (take 2 triplet) | |
theval (last triplet)] | |
(update-in m [thekey] (fnil #(update-the-submap % theval) {})))) | |
(def thetext '("hello" "world" "dogs" "cats" "computer" "mouse" "hello" "world" "cats" "cats" "dogs" "cats" "food" "hello" "world" "dogs")) | |
(def offsettext (conj thetext nil)) |
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
Process.fork { `say -v Kathy -r 70 #{"who who wa doo doo " * 80}`} | |
Process.fork { `say -v Ralph -r 40 #{"dum " * 80}`} | |
Process.fork { `say -v Ralph -r 130 #{"bum dum bum. . . . . . . . . ." * 80}`} | |
Process.fork { `say -v Bruce -r 130 #{"the system is down " * 80}`} |
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 euler.60 | |
(:use euler.prime)) | |
(defn- crude-log [target base] | |
(let [raises (iterate #(* base %) 1)] | |
(first (keep-indexed #(if (> %2 target) %1) raises)))) | |
(defn pairs [unique-elements] | |
(set (for [first-element unique-elements | |
second-element unique-elements |
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 euler.61 | |
(:use euler.prime | |
euler.dfs | |
)) | |
(def naturals (iterate inc 1)) | |
(defn map-naturals [generator] | |
(map generator naturals)) |
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
(defn square [x] (* x x)) | |
(defprotocol Squarable (square [this])) | |
(defrecord SquareRoot [x] | |
Squarable | |
(square [this] x)) | |
(square 4) | |
(square SquareRoot. 5) |
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 euler.challenge | |
(:use euler.dfs)) | |
(def numbers-to-letters | |
{2 ["a" "b" "c"] | |
3 ["d" "e" "f"] | |
4 ["g" "h" "i"] | |
5 ["j" "k" "l"] | |
6 ["m" "n" "o"] | |
7 ["p" "q" "r" "s"] |
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 grapph { | |
;some stuff | |
}) | |
(defn neighbors [node] | |
(get graph node)) | |
(defn dft [node visited-so-far] | |
(let [new-visited-so-far (set (conj visited-so-far node)) | |
unvisited-children (set (remove visited-so-far (set (neighbors node)))) |
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
# This is a combination of 12 commits. | |
# The first commit's message is: | |
more tinker | |
# This is the 2nd commit message: | |
more tinker | |
# This is the 3rd commit message: |
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
(import 'java.text.SimpleDateFormat) | |
(def date-format (SimpleDateFormat. "HH:mm:ss")) | |
(def parsed (.parse date-format "10:22:00")) | |
(.toString parsed) | |
; ---> "Thu Jan 01 10:22:00 CST 1970" |
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
import sys | |
def foo(i): | |
sys.setrecursionlimit(i+5) | |
print(i) | |
foo(i+1) |