style: format code
This commit is contained in:
parent
f49eba9676
commit
3654485f23
2 changed files with 23 additions and 22 deletions
16
Main.hs
16
Main.hs
|
|
@ -10,13 +10,11 @@ import Data.List
|
|||
import Data.Maybe
|
||||
import Proj2
|
||||
|
||||
|
||||
-- | Guess the given target, counting and showing the guesses.
|
||||
guessTest :: [Pitch] -> IO ()
|
||||
guessTest target = do
|
||||
let (guess,other) = initialGuess
|
||||
loop target guess other 1
|
||||
|
||||
let (guess, other) = initialGuess
|
||||
loop target guess other 1
|
||||
|
||||
-- | Given a target and guess and a guess number, continue guessing
|
||||
-- until the right target is guessed.
|
||||
|
|
@ -25,19 +23,17 @@ loop target guess other guesses = do
|
|||
putStrLn $ "Your guess #" ++ show guesses ++ ": " ++ show guess
|
||||
let answer = feedback target guess
|
||||
putStrLn $ " My answer: " ++ show answer
|
||||
if answer == (3,0,0)
|
||||
if answer == (3, 0, 0)
|
||||
then do
|
||||
putStrLn $ "You got it in " ++ show guesses ++ " guesses!"
|
||||
else do
|
||||
let (guess',other') = nextGuess (guess,other) answer
|
||||
loop target guess' other' (guesses+1)
|
||||
|
||||
let (guess', other') = nextGuess (guess, other) answer
|
||||
loop target guess' other' (guesses + 1)
|
||||
|
||||
-- | Parse a string containing a number of space-separated pitches to produce
|
||||
-- a list of pitches. Error if any of the pitches can't be parsed.
|
||||
toChord :: String -> [Pitch]
|
||||
toChord = (fromJust . mapM toPitch . words)
|
||||
|
||||
toChord = fromJust . mapM toPitch . words
|
||||
|
||||
-- | Prompt for a target and use guessTest to try to guess it.
|
||||
main :: IO ()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue