Associative array/Iteration: Difference between revisions

Line 570:
}
}</lang>
 
=={{header|K}}==
Creating a dictionary.
<lang K> d: .((`"hello";1); (`"world";2);(`"!";3))</lang>
 
The keys are available via "!".
<lang K> !d
`hello `world `"!"
 
$!d / convert keys (symbols) as strings
("hello"
"world"
,"!")</lang>
 
Print the key value pairs.
<lang K> `0:{,/$x,": ",d[x]}'!d
hello: 1
world: 2
!: 3</lang>
 
The values are available via "[]".
<lang K> d[]
1 2 3
 
{x+1}'d[]
2 3 4</lang>
 
=={{header|Liberty BASIC}}==
495

edits