How to resolve the algorithm Associative array/Iteration step by step in the Wren programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Associative array/Iteration step by step in the Wren programming language

Table of Contents

Problem Statement

Also show how to iterate just over the keys, or the values, if there is a separate way to do that in your language.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Associative array/Iteration step by step in the Wren programming language

Source code in the wren programming language

// create a new map with four entries
var capitals = {
    "France": "Paris",
    "Germany": "Berlin",
    "Russia": "Moscow",
    "Spain": "Madrid"
}

// iterate through the map and print out the key/value pairs
for (c in capitals) System.print([c.key, c.value])
System.print()

// iterate though the map and print out just the keys
for (k in capitals.keys) System.print(k)
System.print()

// iterate though the map and print out just the values
for (v in capitals.values) System.print(v)

  

You may also check:How to resolve the algorithm Averages/Mean time of day step by step in the Phix programming language
You may also check:How to resolve the algorithm GUI enabling/disabling of controls step by step in the Vala programming language
You may also check:How to resolve the algorithm First perfect square in base n with n unique digits step by step in the Ring programming language
You may also check:How to resolve the algorithm Comma quibbling step by step in the Perl programming language
You may also check:How to resolve the algorithm Imaginary base numbers step by step in the Haskell programming language