RosettaCodeData/Task/Associative-array-Creation/Pop11/associative-array-creation.pop11
Ingy döt Net d066446780 langs a-z
2013-04-10 22:43:41 -07:00

22 lines
620 B
Text

;;; Create expandable hash table of initial size 50 and with default
;;; value 0 (default value is returned when the item is absent).
vars ht = newmapping([], 50, 0, true);
;;; Set value corresponding to string 'foo'
12 -> ht('foo');
;;; print it
ht('foo') =>
;;; Set value corresponding to vector {1 2 3}
17 -> ht({1 2 3});
;;; print it
ht({1 2 3}) =>
;;; Set value corresponding to number 42 to vector {0 1}
{0 1} -> ht(42);
;;; print it
ht(42) =>
;;; Iterate over keys printing keys and values.
appproperty(ht,
procedure (key, value);
printf(value, '%p\t');
printf(key, '%p\n');
endprocedure);