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


 
data "red",      "255 50 50",       "green", "50 255 50",     "blue", "50 50 255"
data "my fave",  "220 120 120",     "black", "0 0 0"
 
myAssocList$ =""
 
for i =1 to 5
    read k$
    read dat$
    call sl.Set myAssocList$, k$, dat$
next i
 
print " Key 'green' is associated with data item "; sl.Get$( myAssocList$, "green")
 