[(1,"blue"),(4,"red"),(2,"yellow")]
之类的内容将变为["blue","yellow","red"]
。
ballots :: [Ballot]
ballots = [b1, b2, b3, b4, b5, b6]
b1 = ["Blue","Green"]
b2 = ["Green","Blue","Red"]
b3 = ["Blue"]
b4 = ["Red","Green"]
b5 = ["Blue","Red","Green"]
b6 = ["Green","Red"]`
选票将投入ns
我得到每个b1的第一个元素,直到b6,头部功能为蓝色,绿色,蓝色,红色,蓝色,绿色。
rank ns = results[head (x) | x<-ns]
结果是我创建的一个函数,它将计算每种颜色的总和,并像这样给出[(1,"red"),(2,"green"),(3,"blue")]
所以,我现在要做的是[(Int, String)]
中没有int的输出
看起来像["red","green","blue"]