我有一个高阶函数,它需要:
results ["Red", "Blue", "Green", "Blue", "Blue", "Red"]
并返回:
[(1,"Green"),(2,"Red"),(3,"Blue")]
我需要使用结果函数并创建一个名为winner的新函数:
winner :: [Party ] -> Party
winner xs =
这将输出最常出现的颜色并删除元组中的第一个元素,如果两种颜色具有相同的出现次数,它将输出两种颜色,例如:
winner ["Red", "Blue", "Green", "Blue", "Blue", "Red"]
输出:
"blue"
到目前为止,我已经尝试使用 snd 和 tail,但我不断收到错误。先感谢您。