Dictionary in POOL is a collection of word-value pairs which allows to access the values (read and write) by using the associated words as keys.

Values can by of any type; different types of values can be stored in a single dictionary. An empty dictionary is created by the plist instruction. Values can be added or modified by setitem instruction or indexing (,) and assignment (:=) operators. Use item instruction or indexing operator (,) to read values. The prefered way of sequential access to {word value} pairs is foreach loop. The order of pairs in a dictionary is set by an internal algorithm.

Dictionary cannot be declared as a constant in a code.

POOL configuration is stored in system variables which are dictionaries:
:sys_inf and :pool_inf - read only;
:pool_cfg - read and write allowed.

Example 1:

Both versions of the code below are equivalent. The first uses traditional LOGO instructions to access values in a dictionary, while the second version the same access is denoted with POOL operators.

make "s plist
print :s
setitem "pass :s "secret
setitem "number :s 12.3
print :s
print item "pass :s

"s := plist
print :s
:s,"pass := "secret
:s,"number := 12.3
print :s
print :s,"pass


[{pass secret} {number 12.3}]

Example 2:

foreach "p :pool_inf [print :p]


{wall_mode wrap}
{turtles_count 1}
{current_fps 0}
{wall_left -396}
{wall_right 396}
{wall_top 195}
{wall_bottom -195}
{image_width 792}
{image_height 390}

See also:

Operations on data sets:
count, emptyp, plistp

Table of Content