Skip to content

Instantly share code, notes, and snippets.

@tsuraan
Created June 8, 2011 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsuraan/1014840 to your computer and use it in GitHub Desktop.
Save tsuraan/1014840 to your computer and use it in GitHub Desktop.
Prelude> let c = Data.ByteString.Lazy.cycle
Loading package bytestring-0.9.1.7 ... linking ... done.
Prelude> let p = Data.ByteString.Lazy.Char8.pack
Prelude> let bfoldr = Data.ByteString.Lazy.foldr
Prelude> let bs = c $ p "hello there"
Prelude> let hasher w ~(pos, hash, lst) = let nhash = hash+(fromIntegral w) in if nhash > 2 then (pos+1, nhash, pos:lst) else (pos+1, nhash, lst)
Prelude> let (_,_,ans) = bfoldr hasher (0, 2, []) bs
Prelude> head ans
^CInterrupted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment