{{ message }}

Instantly share code, notes, and snippets.

# Colin Smith littleredcomputer

Last active Sep 25, 2015
 #!/usr/local/bin/python3 import sys from networkx import nx from pprint import pprint from functools import reduce N = 4 words=[w.strip()
Created Jan 29, 2015
View pell.clj
 (ns cf (:require [clojure.math.numeric-tower :as nt])) (defn- step [x-2 x-1 [a & as]] (when a (let [x (+ (* a x-1) x-2)] (cons x (lazy-seq (step x-1 x as)))))) (defn convergents [as] (let [c (fn c [[h & hs] [k & ks]]
Created Jan 28, 2015
View pell.clj
 (ns cf (:require [clojure.math.numeric-tower :as nt])) (defn- step [x-2 x-1 [a & as]] (when a (let [x (+ (* a x-1) x-2)] (cons x (lazy-seq (step x-1 x as)))))) (defn convergents [as] (let [c (fn c [[h & hs] [k & ks]]
Last active Aug 29, 2015
View cf.clj
 (ns cf (:require [clojure.math.numeric-tower :as nt])) (defn- step [x-2 x-1 [a & as]] (when a (let [x (+ (* a x-1) x-2)] (cons x (lazy-seq (step x-1 x as)))))) (defn convergents [as] (let [c (fn c [[h & hs] [k & ks]]
Last active Aug 29, 2015
Egyptian fractions in Clojure
View gist:9fed7db435d24522fbdb
 (ns ef (:require [clojure.math.numeric-tower :as nt])) (defn ef [r] (loop [r r ef []] (let [x (numerator r) y (denominator r)] (if (= x 1) (conj ef r) (recur (/ (mod (- y) x) (* y (nt/ceil (/ y x)))) (conj ef (/ (nt/ceil (/ y x)))))))))
Last active Aug 29, 2015
View Bugs1.pde
 import java.util.ArrayList; import java.util.List; import processing.core.PVector; List bugs = new ArrayList(); int w = 500; abstract class Actor { protected PVector pos; protected float rot;
Last active Aug 29, 2015
transducers in python
View gist:3140e7cb57c4095ed83f
 summer = lambda acc, val: acc+val maxxer = lambda acc, val: max(acc, val) unioner = lambda acc, val: acc.union({val}) def log(val): print 'value:', val return val print reduce(summer, xrange(5), 0) print reduce(maxxer, xrange(5), 0)
Created Jun 10, 2014
View gist:46a7d17c3126179863c4
 void setup () { fill(255,0,60); stroke(0); rect(50,50,10,10); }