Skip to content

Instantly share code, notes, and snippets.

View jneen's full-sized avatar

Jeanine Adkisson jneen

View GitHub Profile
(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])))
@jneen
jneen / lambda.clj
Last active August 29, 2015 13:59
core.typed and core.match failing to get along, with multimethods this time
(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])))
@jneen
jneen / lambda.hs
Last active August 29, 2015 13:59
what i'm trying to do
data Expr = Var Char
| Lam Char Expr
| App Expr Expr
hasFree :: Char -> Expr -> Bool
hasFree c (Var v) = c == v
hasFree c (Lam arg body) = c /= arg && hasFree c body
hasFree c (App func arg) = hasFree c func && hasFree c arg
@jneen
jneen / gist:d697fbb42399806f46cf
Created May 30, 2014 00:14
/usr/local/bin/wifi
#!/bin/bash
. /usr/lib/network/globals
. "$SUBR_DIR"/wpa
BIN_DIR="$(dirname "$0")"
PREFIX="${WIFI_PREFIX:-$BIN_DIR/..}"
LIB_DIR="$PREFIX/lib/wifi"
NOW="$(date +%s)"
@jneen
jneen / Dockerfile
Created September 5, 2014 18:17
Fig setup
FROM base/devel
RUN pacman --noconfirm -Sy jdk7-openjdk
RUN pacman --noconfirm -Sy socat
ENV LEIN_ROOT 1
RUN curl https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein > /usr/local/bin/lein \
&& chmod +x /usr/local/bin/lein \
&& lein
(defmacro defvariant
[name [[tag & variant-binders] & other-binders] body]
`(defmethod ~name ~tag [[_# ~@variant-binders]
~@other-binders]
~body)
[name [tag & binders] body]
`(defmethod ~name ~tag [[_# ~@binders]] ~body))
; CompilerException java.lang.RuntimeException: Unable to resolve symbol: & in this context, compiling:(/tmp/form-init8620656005427572977.clj:1:1)
class Variant
class Caser
attr_reader :value
def initialize(variant)
@variant = variant
@invoked = false
end
def try_case(tag, &b)
if @variant.tag == tag
@jneen
jneen / cases.rb
Last active August 29, 2015 14:10
module Kernel
def cases(o, cases={})
o = [o] unless o.is_a? Array
raise "invalid" unless o[0].is_a? Keyword
selection = cases[o[0]] || cases[:else] || raise("non-exhaustive cases!")
selection.call(*cases[1..-1])
end
end
#!/usr/bin/env ruby
require 'gtk3'
fname = ARGV[0]
def window(&b)
w = Gtk::Window.new
proc { w.instance_eval(&b) }
end