This file contains 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 game.core | |
(:require [goog.graphics :as gfx] | |
[goog.events :as events] | |
[goog.events.KeyCodes :as key-codes] | |
[goog.events.KeyHandler :as key-handler] | |
[game.ui :as ui]) | |
; core game logic | |
(ui/foo) |
This file contains 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 bool-combinations [vs] | |
(loop [vs vs | |
a '({})] | |
(if (empty? vs) | |
a | |
(recur | |
(rest vs) | |
(flatten | |
(map | |
#(list |
This file contains 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 bool-combinations [vs] | |
(loop [vs vs | |
a '({})] | |
(if (empty? vs) | |
a | |
(recur | |
(rest vs) | |
(flatten | |
(map |
This file contains 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 new-q [] (java.util.concurrent.LinkedBlockingDeque.)) | |
(defn offer! | |
"adds x to the back of queue q" | |
[q x] (.offer q x) q) | |
(defn take! | |
"takes from the front of queue q. if q is empty, block until something is offer!ed into it" | |
[q] (.take q)) |
This file contains 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 my-bus (audio-bus)) | |
;; produce a signal & put it into the bus | |
(defsynth sig-gen [out-bus 0 cps 440 dur 1] | |
(let [env (env-gen (envelope [1 0.00001] [dur] :exponential)) | |
sig (* env (saw cps))] | |
(out out-bus sig))) | |
;; something to read the bus & make it audible |
This file contains 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 latinsq.core | |
(:use [clojure.set :only (difference)])) | |
(defn replace-at | |
"in string s, replaces character at index p with c" | |
[s p c] | |
(str | |
(.substring s 0 p) | |
c |
This file contains 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 dijkstra.core) | |
(def initial-node {:score Integer/MAX_VALUE :route [] :dead? false}) | |
(defn make-initial-state [edges start-node] | |
(-> (zipmap (keys edges) (repeat initial-node)) | |
(assoc-in [start-node :score] 0) | |
(assoc-in [start-node :route] [start-node]))) | |
(defn live-nodes [state] |
This file contains 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 net.mjg123; | |
import org.apache.hadoop.conf.Configuration; | |
import org.apache.hadoop.fs.Path; | |
import org.apache.hadoop.io.IntWritable; | |
import org.apache.hadoop.io.LongWritable; | |
import org.apache.hadoop.io.Text; | |
import org.apache.hadoop.mapreduce.Job; | |
import org.apache.hadoop.mapreduce.Mapper; | |
import org.apache.hadoop.mapreduce.Reducer; |
This file contains 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
(defmacro after | |
"Sleeps for t miliseconds then executes body. Immediately | |
returns a future from which the result of executing body | |
can (eventually) be obtained by `deref`" | |
{:author "Matthew Gilliard"} | |
[t & body] | |
`(future | |
(java.lang.Thread/sleep ~t) | |
~@body)) |
This file contains 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 empty-board [s] | |
{:size s :stones {} :next :black :status :ok}) | |
(def other {:black :white :white :black}) | |
(defn play-stone [brd pos] | |
(-> brd | |
(assoc-in [:stones pos] (brd :next)) | |
(assoc :next (other (brd :next))))) |