Skip to content

Instantly share code, notes, and snippets.

View danking's full-sized avatar

Dan King danking

View GitHub Profile
(* sml *)
fun [] append ys = ys
| (x :: xs) append ys = x :: (xs append ys);
- fun [] append ys = ys
| (x :: xs) append ys = x :: (xs append ys);
stdIn:6.12-6.14 Error: illegal function symbol in clause
stdIn:6.12-7.48 Error: clauses don't all have same function name
stdIn:6.12-7.48 Error: clauses don't all have same number of patterns
stdIn:6.12-7.48 Error: types of rules don't agree [tycon mismatch]
require 'test/unit'
class ParameterizedTestCase < Test::Unit::TestCase
def self.suite
method_names = public_instance_methods(true)
target_method_names = method_names.find_all do |method_name|
method_name =~ /^ptest./
end
puts "target_method_names: #{target_method_names.inspect}"
class MechanicTest < ParameterizedTestCase
@@parameter_parameterized = [["Car", Car.new],
["Bike", Motorcycle.new],
["Truck", Truck.new]]
def ptest_operateOnCar(vehicle)
myMechanic = Mechanic.new
myMechanic.operate(vehicle)
assert !vehicle.broken?
end
@danking
danking / scsh-command-tables-tests-log.scm
Created October 31, 2010 21:52
A scsh error output
Welcome to scsh 0.7
Type ,? for help.
> ,exec ,load load.scm
warning: name from opened structure redefined [package-define!]
#{package 285 config}
srfi-43
#{structure 95 more-structures}
warning: name from opened structure redefined [package-define!]
@danking
danking / weird-scoping.js
Created November 13, 2010 23:27
I get a "Uncaught TypeError: Cannot read property '__e3_' of undefined" error when I execute "new Sojourn(a, b, c)" Stack trace is unhelpful b/c of maps api. Here's a truncated version beginning just after the event handler: Pd main.js:16
function Sojourn(location, map, path) {
var marker = createMarker(location, map);
path.push(location);
this.getLocation = function () { return location; };
this.remove = function () {
marker.setMap(null);
path.forEach(function (x, i) {
if (x.equals(location)) {
path.removeAt(i); }});};
console.log("setting remove behavior!");
(define-struct foo (a))
(define-struct bar (a b c))
;; ---
;; better syntax could probably be thought of...
(struct-dispatch my-var
((foo (a) (do-something a))
((bar (a b c) (do-something-else a b c))))
<statement> ::= <definition>
| <expression>
| "return " <expression>
<definition> ::= "var" <id> " = " <expression>
| "function " <id> " (" <argument-list> ") { " <statements> " }"
<statements> ::= <statment> ";\n" <statements>
| <statement> ";\n"
Welcome to Racket v5.0.2.
> (require racket)
> (define rhino-process (process "rhino"))
> (define rhino-stdin (second rhino-process))
> (define rhino-stdout (first rhino-process))
> (define rhino-stderr (fourth rhino-process))
> (display-lines (list "1 + 1") rhino-stdin)
> (port->string rhino-stdout)
C-c C-cuser break
@danking
danking / gist:740084
Created December 14, 2010 06:47
weird read-line halting
#lang racket
(require rackunit
"main.rkt")
(provide tea-eval auto-cleanup-process)
;; tea-eval : SExp -> (list String String)
;; the first string is (hopefully) the output
;; the second string is the full output of the command, check this if the first
;; doesn't make any sense
(define (tea-eval sexp)