Skip to content

Instantly share code, notes, and snippets.


Erik Ferguson muraiki

View GitHub Profile
View gist:492539f842085f980349
def groupBy[A](xs: List[A]): Map[A, Int] =
xs.foldLeft(Map[A, Int]()) { (m: Map[A, Int], x: A) => m + (x -> (m.get(x).getOrElse(0) + 1)) }
muraiki / fib.pl6
Last active Aug 29, 2015
View fib.pl6
subset NonNegativeInt of Int where * >= 0;
proto fib (|) is cached returns NonNegativeInt {*}
multi fib (0) { 0 }
multi fib (1) { 1 }
multi fib (NonNegativeInt $n) { fib($n - 1) + fib($n - 2) }
say fib(100)
muraiki / core.clj
Created Oct 8, 2014
View core.clj
(ns ajax-to-websocket.core
(:require [org.httpkit.server :as server]
[org.httpkit.client :as client]
[ :as json]
[ :as data]
[clojure.core.async :refer [chan <! >! go timeout onto-chan]]))
(defn channel-closed
"called when websocket channel is closed"
muraiki / my functional things
Created Sep 21, 2013
A concussion has prevented me from doing much coding these past 9 months, but in a fit of boredom I wrote this...
View my functional things
lazy semantics and lambda abstractions
point-free in style and pure computation
memoization gives simple caching
these are a few of my functional things
when the state bites
when the C stings
when impure is bad
I simply remember my functional things
and then I don't feel so mad