Skip to content

Instantly share code, notes, and snippets.

View jneen's full-sized avatar

Jeanine Adkisson jneen

View GitHub Profile
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".
\*/
3^v
;(-*-);
(. .)
(_/___)
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) {
#!/bin/bash
usage() {
cat <<EOF
Usage:
$0 [-r|--recursive] <fname>
$0 [-h|-?|--help]
@jneen
jneen / iter.hs
Last active December 19, 2015 02:09
iter [] step out = out
iter (x:xs) step out = do
val <- x
step val (iter xs out)
@jneen
jneen / monad.java
Last active December 20, 2015 11:39
// 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);
}
@jneen
jneen / monad.py
Last active December 23, 2015 09:49
class Monad:
@staticmethod
def unit(val):
raise NotImplemented
def bind(self, fn):
raise NotImplemented
def map(self, map_fn):
"""
> time node ~/tmp/perf-test.js
dynamic
real 0m0.697s
user 0m0.690s
sys 0m0.013s
> time node ~/tmp/perf-test.js static
static
(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))
@jneen
jneen / lambda.clj
Created April 17, 2014 03:53
core.typed and core.match failing to get along
(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])))