We are superduper-beginners in Haskell and are struggling with a school project. Our goal is to create a working memory test. We have finished everything but the last piece of the puzzle. We want the program to show one word for about a second, and then disappear. Then we want this to be repeated 25 times, for all the 25 words we want to include in the test.
We've been trying to use threadDelay and clearLine without success. Any help we could get is much appreciated, is there some sort of magic function in HASKELL we could use?
This is the only thing we have left to solve.
Hope someone can help us.
/Sara
This is the program so far:
import Data.List
main :: IO Int
main =
do
putStrLn "Hej och välkommen! Du ska nu få testa ditt arbetsminne, i ett litet test. Du kommer få 25 ord presenterade för dig, ett åt gången. Du ska försöka komma ihåg så många ord som möjligt. När du känner dig redo, skriv ditt namn och tryck Enter." --Translation: Hello, this is a working memory test blablabla when ready print redo
name <- getLine
text <- readFile "ord.txt"
let ord = words text
putStrLn "Vilka ord kommer du ihåg? Skriv ner de ord du kommer ihåg, med små bokstäver och mellanslag, utan kommatecken." --Translation: What words do you remember
s <- getLine
let svar = words s
let result1 = map (\x -> elem x ord) svar
let result = filter (\x -> x == True) result1
putStrLn (name ++ "! Av 25 ord kom du ihåg:") --Translation: Out of 25 words you remembered...
return $ length result
We want the part where the words are shown between "name <- getLine" and "text <- readFile "ord.txt" this is what we have tried:
import System.Console.ANSI
import Control.Concurrent
main = do
putStr "hej"
threadDelay 3000000 ; clearLine
putStr "bra jobbat"
We've been trying different locations for threadDelay but it doesn't do what we want it to do.