Skip to content

Instantly share code, notes, and snippets.

@gbluma
Created December 16, 2011 19:14
Show Gist options
  • Save gbluma/1487484 to your computer and use it in GitHub Desktop.
Save gbluma/1487484 to your computer and use it in GitHub Desktop.
Simple Haskell Autocomplete
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