-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
441f4a8
commit 8c02869
Showing
6 changed files
with
76 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
let totalFor country = | ||
sum [row.cities + row.farms + row.industry + row.energy | row <- data, row.country == country]; | ||
let countryData = [ {x: country.country, y: totalFor country.country} | ||
| country <- data] | ||
in BarChart { | ||
caption: "Total Water Consumption By Country", | ||
data: countryData | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[ | ||
{country: "Germany", cities: 1000, farms: 150, industry:500 , energy: 450, popMil: 81}, | ||
{country: "UK", cities: 800, farms: 200, industry: 400, energy: 700, popMil: 67} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
let ratioFor country = | ||
sum [row.popMil / row.farms | row <- data, row.country == country]; | ||
let countryData = [{x: country.country, y: ratioFor country.country} | country <- data] | ||
in BarChart { | ||
caption: "Ratio of farmland consumption to population in millions", | ||
data: countryData | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
let country_water c_name countries_list cities = let city_water = sum [city.water|country <- countries_list, c_name == country.name, city <- cities, elem city.name country.cities]; | ||
let country_water countries_list cities c_name = let city_water = sum [city.water|country <- countries_list, c_name == country.name, city <- cities, elem city.name country.cities]; | ||
farm_water = sum ⸨[country.farms * ⸨3⸩|country <- countries_list, country.name == c_name]⸩ in | ||
city_water + farm_water in | ||
let all_countries = [{name : ⸨"Germany"⸩, cities : ["Berlin", "Hamburg", "Munich"], farms : ⸨100⸩} | ||
, {name : "UK", cities : ["London"], farms : 200} | ||
let all_countries = [{name : "Germany", cities : ["Berlin", "Hamburg", "Munich"], farms : 100} | ||
, {name : ⸨"UK"⸩, cities : ["London", "Birmingham", "Manchester"], farms : ⸨200⸩} | ||
] in | ||
let all_cities = [{name : "Berlin", water : ⸨130⸩} | ||
, {name : "Munich", water : ⸨80⸩} | ||
, {name : "Hamburg", water : ⸨60⸩} | ||
, {name : "London", water : 200} | ||
, {name : "Birmingham", water : 50} | ||
, {name : "Manchester", water : 35} | ||
let all_cities = [{name : "Berlin", water : 130} | ||
, {name : "Munich", water : 80} | ||
, {name : "Hamburg", water : 60} | ||
, {name : "London", water : ⸨200⸩} | ||
, {name : "Birmingham", water : ⸨50⸩} | ||
, {name : "Manchester", water : ⸨35⸩} | ||
] in | ||
country_water ⸨"Germany"⸩ all_countries all_cities | ||
let all_waters countries cities = let c_names = [country.name|country <- countries] in | ||
map (country_water countries cities) c_names in | ||
all_waters all_countries all_cities |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
let country_water c_name countries_list cities = | ||
let country_water countries_list cities c_name = | ||
let city_water = sum [city.water | country <- countries_list | ||
, c_name == country.name | ||
, city <- cities | ||
, elem city.name country.cities]; | ||
farm_water = sum [ country.farms * 3 | country <- countries_list, country.name == c_name ] | ||
in city_water + farm_water; | ||
let all_countries = [{name: "Germany", cities: ["Berlin", "Hamburg", "Munich"], farms: 100}, | ||
{name: "UK", cities: ["London"], farms: 200}]; | ||
{name: "UK", cities: ["London", "Birmingham", "Manchester"], farms: 200}]; | ||
let all_cities = [ | ||
{name: "Berlin", water: 130}, | ||
{name: "Munich", water: 80}, | ||
{name: "Hamburg", water: 60}, | ||
{name: "London", water: 200}, | ||
{name: "Birmingham", water: 50}, | ||
{name: "Manchester", water: 35} | ||
] | ||
in country_water "Germany" all_countries all_cities | ||
]; | ||
let all_waters countries cities = | ||
let c_names = [country.name | country <- countries] | ||
in map (country_water countries cities) c_names | ||
in all_waters all_countries all_cities |