Skip to content

Instantly share code, notes, and snippets.

View chrisamaphone's full-sized avatar

Chris Martens chrisamaphone

View GitHub Profile
$ brew update
error: The following untracked working tree files would be overwritten by merge:
Library/Formula/echoprint-codegen.rb
Library/Formula/rats.rb
Please move or remove them before you can merge.
Aborting
Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master
@chrisamaphone
chrisamaphone / lookupSplit
Created April 2, 2015 15:35
continuation-passing function that returns the value of a key in a table as a (key,value) list, and also the table with that key removed, if it exists.
(* lookupSplit : ''a -> (''a * 'b) list -> ('b * (''a * 'b) list) option *)
fun lookupSplit id table =
let
fun lookupSplit' id nil cont = NONE
| lookupSplit' id ((k,v)::table) cont =
if k = id then SOME (v, cont table)
else lookupSplit' id table (fn suffix => cont ((k,v)::suffix))
in
lookupSplit' id table (fn x => x)
end
@chrisamaphone
chrisamaphone / western-harmony.lf
Last active May 12, 2016 18:38
Twelf description of music harmony presented in http://dreixel.net/research/pdf/fmmh.pdf
root : type.
i : root.
ii : root.
iii : root.
iv : root.
v : root.
vi : root.
vii : root.
v/ : root -> root -> type.

Keybase proof

I hereby claim:

  • I am chrisamaphone on github.
  • I am chrisamaphone (https://keybase.io/chrisamaphone) on keybase.
  • I have a public key whose fingerprint is 2D96 221C 326F 73A4 1070 F26D 05C1 11F8 8E43 92BF

To claim this, I am signing this object:

Generativity Thought Experiment
Suppose I want to generate something, maybe:
- a number
- a string
- a list of numbers
- a set of parameters that define a 3d model
- a game level
- a poem
- a story
@chrisamaphone
chrisamaphone / 17.lp
Created January 5, 2017 02:19
asp solution to 17 puzzle
component(a2).
component(a5).
component(a6).
component(b6).
value(a2, 2).
value(a5, 5).
value(a6, 6).
value(b6, 6).
%% budget proposal
body : type.
governor : body.
house : body.
senate : body.
combined : body.
begin : pred.
proposal body : pred.
On your *ideal* daily commute, how do you get there?
- Drive
- Walk or bike
- Bus or train
- Other
Please make the following assumptions:
- That it takes an identical amount of time (say, 15 minutes) to commute no matter which option you choose.
(Even if you work from home, assume an alternate reality in which you must travel for 15 minutes.)
function randInt(max) { return Math.floor(Math.random()*max) }
function removeIdx(a,i) { return a.splice(i,1)[0] }
function removeRandom(a) {
var i = randInt(a.length);
return removeIdx(a,i)
}
var teams = [3,8,9,10,11,12,14,18,20,21,22,23,24,25];
[Metric("Gold to Enemies Ratio")]
public static float GoldToEnemies(object map)
{
ChunkyLevel sl = (ChunkyLevel)map;
int gold = 0;
int enemies = 0;
for (int i = 0; i < sl.tiles.GetLength(0); i++)
{
for (int j = 0; j < sl.tiles.GetLength(1); i++)
{