This is my first post, so I figured I would post it on forums rather than spamming IRC. I'm wondering, what would be some useful features I could add that would make a Scrabble cheater's life easier?


Code:

module Main where

import Control.Monad (forever)
import Data.Char (toUpper)
import Data.List (isSubsequenceOf, sort)
import Data.Set (isSubsetOf)

wordDictionary :: IO [(String, String)]
wordDictionary = map (\x -> (sort x, x)) . lines <$> readFile "wordlist.txt"

findWords :: [([Char], b)] -> [Char] -> [b]
findWords dictionary charseq =
  let sortedsequence = sort $ map toUpper charseq
   in map snd $ filter (\(x, y) -> x `isSubsequenceOf` sortedsequence) dictionary

main :: IO ()
main = forever $ main' =<< wordDictionary
  where
    main' dictionary = print . findWords dictionary =<< getLine


This is my Haskell file so you can see the logic. Smile

Maybe I'll port it to a Ti 84 CE Razz Graphing Calculator
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement