refactor: fully qualify Set module for clarity
This commit is contained in:
parent
136ba9d1d5
commit
0ce98af868
1 changed files with 6 additions and 6 deletions
12
Proj2.hs
12
Proj2.hs
|
|
@ -58,7 +58,7 @@ import Data.Function (on)
|
||||||
import Data.List
|
import Data.List
|
||||||
import Data.Map qualified as Map
|
import Data.Map qualified as Map
|
||||||
import Data.Ord (comparing)
|
import Data.Ord (comparing)
|
||||||
import Data.Set qualified as S
|
import Data.Set qualified as Set
|
||||||
|
|
||||||
-- ==== DATA STRUCTURES =======================================================
|
-- ==== DATA STRUCTURES =======================================================
|
||||||
|
|
||||||
|
|
@ -142,17 +142,17 @@ feedback target guess = (pitches, notes, octaves)
|
||||||
where
|
where
|
||||||
-- since pitches are unique in a guess,
|
-- since pitches are unique in a guess,
|
||||||
-- we can use set math to count how many are correct
|
-- we can use set math to count how many are correct
|
||||||
targetSet = S.fromList target
|
targetSet = Set.fromList target
|
||||||
guessSet = S.fromList guess
|
guessSet = Set.fromList guess
|
||||||
|
|
||||||
pitchSet = S.intersection targetSet guessSet
|
pitchSet = Set.intersection targetSet guessSet
|
||||||
pitches = length pitchSet
|
pitches = length pitchSet
|
||||||
|
|
||||||
-- since notes and octaves are not unique in a guess,
|
-- since notes and octaves are not unique in a guess,
|
||||||
-- we can compare the guess to all possible permutations of the target
|
-- we can compare the guess to all possible permutations of the target
|
||||||
-- and count the pairwise note/octave matches
|
-- and count the pairwise note/octave matches
|
||||||
targetNoPitches = S.toList $ S.difference targetSet pitchSet
|
targetNoPitches = Set.toList $ Set.difference targetSet pitchSet
|
||||||
guessNoPitches = S.toList $ S.difference guessSet pitchSet
|
guessNoPitches = Set.toList $ Set.difference guessSet pitchSet
|
||||||
notes = matches (map note targetNoPitches) (map note guessNoPitches)
|
notes = matches (map note targetNoPitches) (map note guessNoPitches)
|
||||||
octaves = matches (map octave targetNoPitches) (map octave guessNoPitches)
|
octaves = matches (map octave targetNoPitches) (map octave guessNoPitches)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue