Created
December 16, 2011 19:14
-
-
Save gbluma/1487484 to your computer and use it in GitHub Desktop.
Simple Haskell Autocomplete
This file contains hidden or 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 Data.List | |
import Data.List.Utils | |
import Data.Function | |
main = do | |
contents <- readFile "BingBodyJun09_Top100KWords.txt" | |
-- break into lines | |
let rows = lines contents | |
-- read input from user | |
userInput <- getLine | |
-- search on input for a completed version of it | |
let filtered = filter (startswith userInput) | |
rows | |
mapM print $ take 15 filtered |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment