RosettaCodeData/Task/Associative-array-Creation/EMal/associative-array-creation.emal

12 lines
676 B
Text
Raw Permalink Normal View History

2024-10-16 18:07:41 -07:00
Map empty ← Map(int, text) # creates an empty map
2023-07-01 11:58:00 -04:00
writeLine(empty)
2024-10-16 18:07:41 -07:00
var longFruit ← Map(int, text).of(1, "banana") # creates a map with the pair 1 ⇒ "banana"
longFruit[2] ← "melon" # associates a key of 2 with "melon"
2023-07-01 11:58:00 -04:00
longFruit.insert(3, "avocado")
writeLine(longFruit) # prints the map
2024-10-16 18:07:41 -07:00
var shortFruit ← int%text[4 ⇒ "kiwi", 5 ⇒ "apple"] # map creation using arrow notation
2023-07-01 11:58:00 -04:00
writeLine(shortFruit[5]) # retrieves the value with a key of 5 and prints it out
writeLine(shortFruit.length) # prints the number of entries
writeLine(shortFruit) # prints the map
2024-10-16 18:07:41 -07:00
writeLine(text%text["Italy" ⇒ "Rome", "France" ⇒ "Paris", "Germany" ⇒ "Berlin", "Spain" ⇒ "Madrid"])