- Read a table of data from disk
Cassava: exploratory CSV parsing
| package object tasks { | |
| trait Task[A, B] { | |
| private[tasks] def run(): Either[A, B] | |
| def map[C](f: B => C): Task[A, C] = ??? | |
| def flatMap[C](f: B => Task[A, C]): Task[A, C] = ??? | |
| } | |
| private[tasks] class Http[A, B]( | |
| data: HttpRequest, | |
| handler: Either[Throwable, HttpResponse] => Either[A, B], |
| #!/usr/bin/env runhaskell | |
| {- Project Euler 96 - Solve Sudoku! | |
| - | |
| - Compile it with ghc -o blah --make sudoku | |
| - | |
| - And grab sudoku.txt from | |
| - http://projecteuler.net/index.php?section=problems&id=96 | |
| - | |
| - Answer: 24702 |
| #!/usr/bin/env runhaskell | |
| {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, TypeSynonymInstances, FunctionalDependencies #-} | |
| {- Monad-like trees can do cool things like factoring integers and | |
| - pruning leaves with bind (>>=). | |
| - | |
| - Internal nodes are annotated with a measure of some sort that can be used | |
| - for efficient indexing and sizing. | |
| - | |
| - Measured typeclass and tagged nodes from |
| #!/usr/bin/env python | |
| """ | |
| Translated from the example in | |
| Deprecating the Observer Pattern (Maier, Rompf, Odersky) | |
| http://lamp.epfl.ch/~imaier/pub/DeprecatingObserversTR2010.pdf | |
| Their Scala example: | |
| Reactor.once { self => | |
| // step 1: |
| #!/usr/bin/env python | |
| """ | |
| Tail-Recursion helper in Python. | |
| Inspired by the trampoline function at | |
| http://jasonmbaker.com/tail-recursion-in-python-using-pysistence | |
| Tail-recursive functions return calls to tail-recursive functions | |
| (themselves, most of the time). For example, this is tail-recursive: |