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
--- module ScottsSnake where | |
import Keyboard | |
import Random | |
import String | |
import Set | |
type Position = {x: Int, y: Int } | |
type Board = {w: Int, h: Int, wall: [Position]} | |
type Apple = Position |
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 ack [m n] | |
(cond (zero? m) (inc n) | |
(zero? n) (ack (dec m) 1) | |
:else (ack (dec m) (ack m (dec n))))) | |
(defn ack-cps | |
([m n] (ack-cps m n identity)) | |
([m n k] | |
(loop [m m, n n, k k] | |
(cond (zero? m) (k (inc n)) |
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
Host nfsn | |
Hostname ssh.phx.nearlyfreespeech.net | |
Host * | |
IdentityFile ~/.ssh/id_fibonatch_auto | |
IdentityFile ~/.ssh/id_fibonatch_weak |
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 shuffle.core | |
(:use (incanter core charts))) | |
; naive, O(n+m) | |
(defn take-rand1 [n coll] (take n (shuffle coll))) | |
; lazy, O(n!@#$%m^&) | |
(defn take-rand2 [n coll] | |
(let [coll (vec coll)] | |
(take n (distinct (repeatedly #(rand-nth coll)))))) |
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 tricky-logic [x] | |
(cond (or (cheap-test1) | |
(expensive-test)) | |
(...body1...) | |
(and (cheap-test2) | |
(expensive-test)) | |
(...body2...) | |
:else (expensive-test))) | |
;; rewrite to avoid repeating tests *or* code: |
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 my-memo [f] | |
(let [cache (atom {})] | |
(fn [& args] | |
(force (get (swap! cache update-in [args] | |
#(or % (delay (apply f args)))) | |
args))))) |
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
#################################### | |
# BASIC REQUIREMENTS | |
# http://graphite.wikidot.com/installation | |
# http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/ | |
# Last tested & updated 10/13/2011 | |
#################################### | |
sudo apt-get update | |
sudo apt-get upgrade |
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
(->> [1] | |
(iterate (fn [row] | |
(for [[a b] (partition 2 1 | |
(concat [0] row [0]))] | |
(+ a b)))) | |
(take 10)) | |
([1] (1 1) (1 2 1) (1 3 3 1) (1 4 6 4 1) (1 5 10 10 5 1) (1 6 15 20 15 6 1) (1 7 21 35 35 21 7 1) (1 8 28 56 70 56 28 8 1) (1 9 36 84 126 126 84 36 9 1)) |
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
;; amalloy's solution to http://4clojure.com/problem/58 | |
(fn [& fs] | |
(reduce (fn [f g] | |
(fn [& x] (f (apply g x)))) | |
fs)) |
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 shuffle.core | |
(:use (incanter core charts))) | |
; naive, O(n+m) | |
(defn take-rand1 [n coll] (take n (shuffle coll))) | |
; lazy, O(n!@#$%m^&) | |
(defn take-rand2 [n coll] | |
(let [coll (vec coll)] | |
(take n (distinct (repeatedly #(rand-nth coll)))))) |
NewerOlder