Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {-
- Construcao do Conhecimento
- Times do Campeonato Amazonense:
- Codigo Nome
- 00 Nacional
- 01 Sao Raimundo
- 02 Gremio Coariense
- 03 Rio Negro
- 04 Fast
- 05 Libermorro
- 06 America
- 07 Sulamerica
- Entrada:
- [
- [codigo_time_1, codigo_time2, gols_time1, gols_time2, turno_da_partida]
- ...
- ]
- Exemplo de entrada:
- [[1, 2, 0, 2, 1], [1, 3, 3, 1, 1], ...]
- -}
- get_team_name cod =
- if (cod == 0) then
- "Nacional"
- else
- if (cod == 1) then
- "Sao Raimundo"
- else
- if (cod == 2) then
- "Gremio Coariense"
- else
- if (cod == 3) then
- "Rio Negro"
- else
- if (cod == 4) then
- "Fast"
- else
- if (cod == 5) then
- "Libermorro"
- else
- if (cod == 6) then
- "America"
- else
- if (cod == 7) then
- "Sulamerica"
- else
- ""
- evaluate_match match =
- if (team1_goals_scored == team2_goals_scored) then
- [team1_cod, team2_cod, 1, 1, turn]
- else
- if (team1_goals_scored > team2_goals_scored) then
- [team1_cod, team2_cod, 3, -1, turn]
- else
- [team1_cod, team2_cod, -1, 3, turn]
- where
- [team1_cod, team2_cod, team1_goals_scored, team2_goals_scored, turn] = match
- calc_team_score matches team_code turn =
- foldl aux_f 0 matches
- where
- aux_f team_total_points match =
- if (turn == match_info !! 4) then
- if (team_code == match_info !! 0) then
- team_total_points + (match_info !! 2)
- else
- if (team_code == match_info !! 1) then
- team_total_points + (match_info !! 3)
- else
- team_total_points
- else
- team_total_points
- where
- match_info = evaluate_match match
- show_scoreboard names scores =
- [(names !! i, scores !! i) | i <- [0, 1..7]]
- am_soccer_championship_scoreboard matches =
- [
- show_scoreboard teams_names turn1_points,
- show_scoreboard teams_names turn2_points,
- show_scoreboard teams_names total_points
- ]
- where
- turn1_points = [(calc_team_score matches team_code 1) | team_code <- [0, 1..7]]
- turn2_points = [(calc_team_score matches team_code 2) | team_code <- [0, 1..7]]
- total_points = [((turn1_points !! i) + (turn2_points !! i)) | i <- [0, 1..7]]
- teams_names = [(get_team_name i) | i <- [0, 1..7]]
Add Comment
Please, Sign In to add comment