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
ex05: | |
A minor thing, but ruby programmers almost never use string formatters. I find #{} interpolation to be prettier and easier to understand. | |
ex09: | |
minor: in the heredoc text there's a reference to "three quotes", which aren't actually there. | |
ex12: | |
The word 'module' is used to describe the 'open-uri' library. In Ruby, libraries *usually* define modules, but modules are actually much more general, and an important concept to learn in their own right. The extra credit does say to learn the difference between "require" and "include", but these are such different concepts in Ruby that I think overloading the term at the beginning just sets up the student for confusion later. | |
require 'open-uri' # this is a library that we are ensuring is available. Often these come from "gems". |
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
\*/ | |
3^v | |
;(-*-); | |
(. .) | |
(_/___) |
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 P = require('pjs').P; | |
var util = require('util'); | |
var stack = function() { | |
return (new Error).stack.split(/\s+at\s+/).slice(1); | |
} | |
var slice = [].slice; | |
var Thunk = P(function(thunk) { |
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
#!/bin/bash | |
usage() { | |
cat <<EOF | |
Usage: | |
$0 [-r|--recursive] <fname> | |
$0 [-h|-?|--help] |
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
iter [] step out = out | |
iter (x:xs) step out = do | |
val <- x | |
step val (iter xs out) |
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
// what i assume the callbacks look like | |
abstract class Callback<T> { | |
abstract void run(T data); | |
} | |
// the binding function a -> m b | |
abstract class Step<T, U> { | |
abstract Action<U> into(final T data); | |
} |
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 Monad: | |
@staticmethod | |
def unit(val): | |
raise NotImplemented | |
def bind(self, fn): | |
raise NotImplemented | |
def map(self, map_fn): | |
""" |
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
> time node ~/tmp/perf-test.js | |
dynamic | |
real 0m0.697s | |
user 0m0.690s | |
sys 0m0.013s | |
> time node ~/tmp/perf-test.js static | |
static |
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 rec [expr] | |
(match expr | |
[:global] 'GLOBAL | |
[:constant x] x | |
[:variable x] x | |
[:lazy-variable x] `(deref ~x) | |
[:if test if-true if-false] `(if ~(rec test) | |
~(rec if-true) | |
~(rec if-false)) | |
[:delist list index] `(get ~(rec list) ~(rec index)) |
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 type-test.lambda | |
(require [clojure.core.typed :refer :all] | |
[clojure.core.match :refer [match]])) | |
(def-alias Expr "An expression" | |
(Rec [e] | |
(U '[(Value :var) Symbol] | |
'[(Value :lam) Symbol e] | |
'[(Value :app) e e]))) |