Task

The goal is to create an associative array (also known as a dictionary, map, or hash).



Related tasks:

 Associative arrays/Iteration
 Hash from two arrays


See also

 Array
 Associative array: Creation, Iteration
 Collections
 Compound data type
 Doubly-linked list: Definition, Element definition, Element insertion, List Traversal, Element Removal
 Linked list
 Queue: Definition, Usage
 Set
 Singly-linked list: Element definition, Element insertion, List Traversal, Element Removal
 Stack


using System;
using System.Console;
using Nemerle.Collections;
 
module AssocArray
{
    Main() : void
    {
        def hash1 = Hashtable([(1, "one"), (2, "two"), (3, "three")]);
        def hash2 = Hashtable(3);
        foreach (e in hash1)
            hash2[e.Value] = e.Key;
        WriteLine("Enter 1, 2, or 3:");
        def entry = int.Parse(ReadLine());
        WriteLine(hash1[entry]);
    }
}