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
inc = function(x) { | |
return x + 1; | |
}; | |
square = function(x) { | |
return x * x; | |
}; | |
cube = function(x) { | |
return x * x * x; |
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
commands = ["look", "smell"] | |
def make_room(description, exits): | |
def room(skip = False, command = ""): | |
if not skip or command == "look": | |
print description | |
print "You can go: " + ",".join(exits.keys()) | |
if command in exits.keys(): | |
return rooms[exits[command]] | |
if command and command not in commands: | |
print "I don't understand that." |
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
class Message(object): | |
def __init__(self, string): | |
self.breakdown = [] | |
self.tokens = {} | |
for part in string.split('{'): | |
self.breakdown.extend(part.split('}')) | |
for i, part in enumerate(self.breakdown): | |
if i % 2 == 1: |
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
enum Operation { | |
Add, | |
Sub, | |
Mul, | |
Div, | |
Exp | |
} | |
impl Operation { | |
fn apply(self, a : int, b : int) -> int { |
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
( | |
var notes, on, off; | |
MIDIClient.init; | |
MIDIIn.connect(); | |
SynthDef.new(\MonoSaw, { | |
|freq = 440, amp = 0.2, | |
dur = 1, gate = 0, |
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
/* | |
* robotNav.js | |
* | |
* The green key is located in a slightly more | |
* complicated room. You'll need to get the robot | |
* past these obstacles. | |
*/ | |
function startLevel(map) { | |
// Hint: you can press R or 5 to "rest" and not move the |
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
{ | |
"Alabama":{ | |
"name":"Alabama", | |
"borders":[ | |
"Mississippi", | |
"Tennessee", | |
"Georgia", | |
"Florida" | |
] | |
}, |
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
{- rps.hs Simple Rock Paper Scissors written in Haskell | |
- for translation to Ocaml as a learning exercise. | |
-} | |
data Move = Rock | Paper | Scissors deriving (Show, Eq) | |
data Player = Player String deriving (Show, Eq) | |
data Outcome = Winner Player | Tie deriving (Show, Eq) |
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 markov.experiment | |
(:require [clojure.string :as string])) | |
(defn wrand [m] | |
(let [total (reduce + (vals m)) | |
r (rand total)] | |
(loop [ks (keys m) sum 0] | |
(if (< r (+ (get m (first ks)) | |
sum)) | |
(first ks) |
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
var PDFDocument = require('pdfkit'); | |
var fs=require('fs'); | |
var process = require('process') | |
var captureText = function(cb) { | |
var text = "" | |
process.stdin.on('readable', () => { | |
chunk = process.stdin.read(); | |
if(chunk) text = text + chunk; | |
}); |
OlderNewer