In this exercise you'll be writing code to keep track of international dialing codes via an international dialing code hashmap.
The map uses an integer for its keys (the dialing code) and a string (country name) for its values.
You have 11 tasks which involve dialing-codes.
There exists a pre-populated hashmap which contains the following 3 dialing codes: "United States of America" which has a code of 1, "Brazil" which has a code of 55 and "India" which has a code of 91. Define the countries var to store the pre-populated hashmap:
countries
;;=> {1 "United States of America", 55 "Brazil", 91 "India"}Add "United Kingdom" with a dialing code of 44 to the map created in task 1:
(add-country countries 44 "United Kingdom")
;;=> {1 "United States of America", 44 "United Kingdom", 55 "Brazil", 91 "India"}Retrieve the name of the country with dialing code 55
(country-name countries 55)
;;=> "Brazil"Change the name of "United States of America" to "Les États-Unis":
(update-map countries 1 "Les États-Unis")
;;=> {1 "Les États-Unis", 55 "Brazil", 91 "India"}Check that a record for Brazil exists in the map created in task 1
(code-exists? countries 55)
;;=> trueTry to change the name of a country with a code that is not in the map e.g. 999. This should result in no change to the map:
(update-map countries 999, "Newlands")
;;=> {1 "United States of America", 44 "United Kingdom", 55 "Brazil", 91 "India"}Remove India from the map:
(remove-country countries 91)
;;=> {1 "United States of America", 55 "Brazil"}Process the values in the map to find the one with the longest name:
(longest-name countries)
;;=> "United States of America"In this exercise you'll be writing code to keep track of international dialing codes via an international dialing code hashmap.
The map uses an integer for its keys (the dialing code) and a string (country name) for its values.
You have 11 tasks which involve dialing-codes.
There exists a pre-populated hashmap which contains the following 3 dialing codes: "United States of America" which has a code of 1, "Brazil" which has a code of 55 and "India" which has a code of 91. Define the countries var to store the pre-populated hashmap:
countries
;;=> {1 "United States of America", 55 "Brazil", 91 "India"}Add "United Kingdom" with a dialing code of 44 to the map created in task 1:
(add-country countries 44 "United Kingdom")
;;=> {1 "United States of America", 44 "United Kingdom", 55 "Brazil", 91 "India"}Retrieve the name of the country with dialing code 55
(country-name countries 55)
;;=> "Brazil"Change the name of "United States of America" to "Les États-Unis":
(update-map countries 1 "Les États-Unis")
;;=> {1 "Les États-Unis", 55 "Brazil", 91 "India"}Check that a record for Brazil exists in the map created in task 1
(code-exists? countries 55)
;;=> trueTry to change the name of a country with a code that is not in the map e.g. 999. This should result in no change to the map:
(update-map countries 999, "Newlands")
;;=> {1 "United States of America", 44 "United Kingdom", 55 "Brazil", 91 "India"}Remove India from the map:
(remove-country countries 91)
;;=> {1 "United States of America", 55 "Brazil"}Process the values in the map to find the one with the longest name:
(longest-name countries)
;;=> "United States of America"