-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEFA.hs
More file actions
34 lines (25 loc) · 966 Bytes
/
EFA.hs
File metadata and controls
34 lines (25 loc) · 966 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
module EFA where
import System.Random (randomRIO)
import Control.Monad (replicateM)
data EFAResult = EFAResult [Result]
instance Show EFAResult where
show (EFAResult rs) = (show numTrue) ++ " out of " ++ (show total)
where identity a = a
numTrue = length (filter identity bools)
total = length bools
bools = map fst rs
type Result = (Bool, [Char])
class EFA a where
fromArgs :: [String] -> [a]
genEFA :: [String] -> ([String] -> [a]) -> [a] -> [a]
genEFA args processArgs defaults =
if (null args) then defaults else processArgs args
class EFAQ a where
train :: a -> Integer -> Result
genMessage :: (Eq a, Show a) => a -> a -> String
genMessage actual guess =
if actual == guess
then "Correct! "
else "Incorrect... " ++ (show actual)
randos :: Integer -> Integer -> IO [Integer]
randos n max = replicateM (fromIntegral n) (randomRIO (1, max) :: IO Integer)