This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 = {} |