From bca6ee723d423f6394b75ba5c85d99ae3472bab1 Mon Sep 17 00:00:00 2001 From: wi11-holdsworth <83637728+wi11-holdsworth@users.noreply.github.com> Date: Wed, 1 Oct 2025 14:34:35 +1000 Subject: [PATCH] docs: comment helper functions --- Proj2.hs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Proj2.hs b/Proj2.hs index 7631262..ff9f91e 100644 --- a/Proj2.hs +++ b/Proj2.hs @@ -162,12 +162,25 @@ nextGuess (prevGuess, chord : chords) _ = (chord, chords) -- ==== HELPER FUNCTIONS ====================================================== +-- given lists xs and ys, calculates the maximum number of pairwise matches +-- between xs and all permutations of ys +-- +-- used in the feedback function to calculate the number of correct notes +-- and/or octaves +-- 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 +-- outputs a list of all possible chords, where a chord is a list of unique +-- pitches. this function happens to generate chords such that the pitches are +-- in alphabetical order, but this is only to ensure that there are no +-- duplicate pitches +-- +-- used in initialGuess as the game state (represents all possible targets) +-- allChords :: [[Pitch]] allChords = [ chord