Skip to content

Instantly share code, notes, and snippets.


Sam Ritchie sritchie

View GitHub Profile
sritchie /
Created Feb 2, 2011
Hadoop input format for swallowing entire files.
package forma;
import forma.WholeFileInputFormat;
import cascading.scheme.Scheme;
import cascading.tap.Tap;
import cascading.tuple.Fields;
import cascading.tuple.Tuple;
import cascading.tuple.TupleEntry;
import org.apache.hadoop.mapred.JobConf;
View fuck.js
(function () {function b(a){throw a;}var f=!0,h=null,j=!1;function aa(){return function(a){return a}}function k(a){return function(){return this[a]}}function m(a){return function(){return a}}var o;
function q(a){var c=typeof a;if("object"==c)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return c;var;if("[object Window]"==d)return"object";if("[object Array]"==d||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==d||"undefined"!=typeof"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";
else if("function"==c&&"undefined"==typeof"object";return c}function s(a){return void 0!==a}function ba(a){return"string"==typeof a}function ca(a){return a[da]||(a[da]=++ea)}var da="closure_uid_"+Math.floor(2147483648*Math.random()).toString(36),ea=0;var fa={"\x00":"\\0","\u
sritchie / multivariate.cljc
Last active Jan 18, 2021
multivariate redo attempt...
View multivariate.cljc
;; [[jacobian]] handles this main logic. [[jacobian]] can only take a structural
;; input. [[euclidean]] and [[multivariate]] below widen handle, respectively,
;; optionally-structural and multivariable arguments.
(defn- jacobian
- some function `f` of a single [[s/structure?]] argument
- the unperturbed structural `input`
sritchie / algebra.swift
Created Jun 9, 2014
Typeclasses in Swift
View algebra.swift
// Playground - noun: a place where people can play
import Cocoa
var str = "Hello, playground"
// Here's take 1. First, I defined the algebra like I would in
// Scala, as separate protocols:
protocol Semigroup {
typealias T
View replace_tag.scm
(define ((replace-differential-tag oldtag newtag) object)
(cond ((differential? object)
(map (lambda (term)
(let ((terms (differential-tags term)))
(cond ((and (memv oldtag terms)
(memv newtag terms))
(remove-differential-tag newtag (remove-differential-tag oldtag terms))
View bug.scm
;; Here is the smoking gun...
(define (f x)
(lambda (cont)
(cont (lambda (y) (* x y))
(lambda (g) (g x)))))
;; (D f) is:
(lambda (cont)
View sci.cljc
(ns sicmutils.sci
(:require [sicmutils.env :as env]
[sci.core :as sci]))
(defn ns-bindings
"Returns a pair of
- `(ns-publics sym)` fn entries
- `(ns-publics sym)` macro entries"
sritchie / refman.adoc
Created Dec 12, 2020
SICMUtils Reference Manual (ported from the original)
View refman.adoc

SICMUTILS Reference Manual

This is a port of the original reference manual for scmutils over to Clojure and the SICMUtils API. The goal here is to host an annotated version of the original refman.txt, highlighting any difference in functionality, behavior and naming so that folks can transition between the systems. The code here assumes that you’re working at a REPL initialized to the the sicmutils.env namespace.
sritchie /
Created Dec 12, 2020
v0.14.0: tons of new generic operations, refman ported!
  • we have a great documentation site now! cljdoc now hosts a full port of the original scmutils reference manual. All code snippets in the ported refman now work. I've also distributed many of the sections in the reference manual into more topically organized sections in the cljdoc site, so give those a browse and keep your eye out for more expansion there.

Okay, on to the beefy changelog.

A quick note: After the work below, v/nullity? renamed to v/zero?, and v/unity? renamed to v/one? #180. This affects the names listed in the CHANGELOG entries below.

New Generic Functions

This release brings us closer to the interface provided by scmutils.

View adaptive.clj
(defn adaptive
"Accepts two 'integrator' functions of:
- `f`: some integrand
- `a` and `b`: the lower and upper endpoints of integration
- `opts`, a dictionary of configuration options
And returns a new function of the same signature that adaptively subdivides
the region $a, b$ into intervals if integration fails to converge."
([integrator] (adaptive integrator integrator))