Skip to content

Instantly share code, notes, and snippets.

View darius's full-sized avatar

Darius Bacon darius

View GitHub Profile
@darius
darius / nfa.hs
Last active May 1, 2016 03:08 — forked from emhoracek/nfa.hs
import qualified Data.Array as A
import Data.List (nub)
import Data.Monoid ((<>))
spec = do
print (many (lit 'a') `shouldMatch` "aaa")
print (many (lit 'a' `alt` lit 'a') `shouldNotMatch` "aaacf")
print (many (lit 'a' `alt` lit 'b') `shouldMatch` "abababa")
print ((lit 'a' . many (lit 'b' `alt` lit 'c') . lit 'd') `shouldMatch` "abcbd")
"""
Test out 20 binary-search functions harvested from
http://reprog.wordpress.com/2010/04/19/are-you-one-of-the-10-percent/
See results at the bottom.
"""
import random
failures = {}