Closed marperia closed 12 months ago
Hi There, thanks for this.
Just for reference, the example solution has this, which is a bit simpler
aggregateScorers : List PlayerName -> Dict PlayerName Int
aggregateScorers playerNames =
List.foldl updateGoalCountForPlayer Dict.empty playerNames
I think you could use either List.foldl
or List.foldr
here though, so we could update the rules to allow for this.
And maybe we should add something to the hints for List.foldl
and List.foldr
. We don't teach every function of every module, as it would take a long time to develop, and a long time for the student to complete, and probably be a bit boring. The idea is more to give students the basic building blocks, and provide links to the documentation for the more detailed things.
@ceddlyburge my updateGoalCountForPlayer
function looks like this
updateGoalCountForPlayer : PlayerName -> Dict PlayerName Int -> Dict PlayerName Int
updateGoalCountForPlayer playerName playerGoalCounts =
Dict.update playerName (Maybe.map (\x -> x + 1)) playerGoalCounts
and it doesn't pass test with your example. I need pre-generated dictionary to update values because of using Dict.update
instead of using this
updateGoalCountForPlayer : PlayerName -> Dict PlayerName Int -> Dict PlayerName Int
updateGoalCountForPlayer playerName playerGoalCounts =
let
currentCount =
Dict.get playerName playerGoalCounts
in
case currentCount of
Just count ->
Dict.insert playerName (count + 1) playerGoalCounts
Nothing ->
Dict.insert playerName 1 playerGoalCounts
But I will be appreciated if you correct me because I'm newbie in Elm.
Hi There, this sort of question is probably best answered through the mentoring part of exercism. They will be able to see all your code for example, and the discussion bits are probably better suited to it.
Have you asked for a mentor to look at your code?
@marperia , I can see a solution of yours to Paola's Prestigious Pizza, but nothing for Top Scorers. (Also, the pizza exercise is quite difficult, but it looks like you have completed it ok ...)
I wrote a function
But I see
essential
badgeP. S. It's not easy to understand that I should use List.foldr because there is no foldr examples anywhere else!!!