ezyang’s blog

the arc of software bends towards understanding

Cup of FP with a Java twist

zip: List<A>, List<B> -> List<(A, B)> zip(Nil, Nil) = Nil zip(_, Nil) = Nil zip(Nil, _) = Nil zip(Cons(a, as), Cons(b, bs)) = Cons((a, b), zip(as, bs)) fst: (A, B) -> A fst((a, _)) = a last: List<A> -> A last(Cons(a, Nil)) = a last(Cons(a, as)) = last(as) foldl: (B, A -> B), B, List<A> […]

  • April 5, 2010