Elm:折叠多个列表的特定值
我有一个“游戏”记录列表,每个玩家都有一个分数列表。 是否可以将每场比赛中每位球员的每场得分折叠起来,以显示“总得分” 比如:Elm:折叠多个列表的特定值,elm,Elm,我有一个“游戏”记录列表,每个玩家都有一个分数列表。 是否可以将每场比赛中每位球员的每场得分折叠起来,以显示“总得分” 比如: games = [ { id = 1 , points = [ { player_id = 1, score = 20 } , { player_id = 2, score = 10 } , { player_id = 3, score = 0 } ]
games =
[ { id = 1
, points =
[ { player_id = 1, score = 20 }
, { player_id = 2, score = 10 }
, { player_id = 3, score = 0 }
]
}
, { id = 2
, points =
[ { player_id = 1, score = 20 }
, { player_id = 2, score = 5 }
, { player_id = 3, score = 0 }
]
}
, { id = 3
, points =
[ { player_id = 1, score = 20 }
, { player_id = 2, score = 5 }
, { player_id = 3, score = 10 }
]
}
]
提前谢谢。您需要一个双折,钥匙代码在那里
[ { player_id = 1, score = 60 }
, { player_id = 2, score = 20 }
, { player_id = 3, score = 10 }
]
见[ellie)
这会得到您想要的答案,尽管格式略有不同您需要一个双折,其中关键代码是
[ { player_id = 1, score = 60 }
, { player_id = 2, score = 20 }
, { player_id = 3, score = 10 }
]
见[ellie)
这会得到您想要的答案,尽管格式略有不同