Skip to content

Instantly share code, notes, and snippets.

@pnf
pnf / drawgraph.py
Created June 21, 2013 12:47
Draw a sort-of-pretty ascii graph from input data in outline form.
#!/usr/bin/env python
import re
import sys
from collections import deque
class Frame:
def __init__(self,node,indent):
self.node = node
self.indent = indent
@pnf
pnf / mapf
Created June 10, 2013 16:47
Explore sequential composition and chained futures
object mapfunc {
println("Let's do wacky things with lists") //> Let's do wacky things with lists
import scala.concurrent._
import ExecutionContext.Implicits.global
// Hold a list of functions of no arguments producing A
class SeqF[A] (l : Seq[()=>A]) {
def map[B](f : A =>B) = new SeqF(l.map( x => () => f(x())))
def scanLeft[B](b0 : B)(f : (B,A)=>B) : SeqF[B] = {