diff --git a/Proj2.hs b/Proj2.hs index 9c67d4a..7631262 100644 --- a/Proj2.hs +++ b/Proj2.hs @@ -162,6 +162,11 @@ nextGuess (prevGuess, chord : chords) _ = (chord, chords) -- ==== HELPER FUNCTIONS ====================================================== +matches :: (Eq a, Show a) => [a] -> [a] -> Int +matches xs ys = maximum permutationMatches + where + permutationMatches = map (pairwiseMatches xs) (permutations ys) + pairwiseMatches xs ys = length $ filter (uncurry (==)) $ zip xs ys allChords :: [[Pitch]] allChords = @@ -174,22 +179,9 @@ allChords = p1 < p2, p2 < p3 ] - -allPitches :: [Pitch] -allPitches = - [ Pitch note octave - | note <- allNotes, - octave <- allOctaves - ] - -allOctaves :: [Octave] -allOctaves = [minBound .. maxBound] - -allNotes :: [Note] -allNotes = [minBound .. maxBound] - -matches :: (Eq a, Show a) => [a] -> [a] -> Int -matches xs ys = maximum permutationMatches where - permutationMatches = map (pairwiseMatches xs) (permutations ys) - pairwiseMatches xs ys = length $ filter (uncurry (==)) $ zip xs ys + allPitches = + [ Pitch note octave + | note <- [minBound .. maxBound], + octave <- [minBound .. maxBound] + ]