Item or character at selected index

item index collection
item index word

ref collection index
ref word index

collection,index
word,index

Returns an item or a character at selected index of the collection or word, respectively.

Accessing items of collections is a frequent operation in programming. The standard LOGO instruction, item, has quite a verbose notation. To make it more compact we introduced in POOL the indexing operator ,.

POOL supports arrays with read-write access to items (while lists and words are immutable). The traditional LOGO instruction setitem allows to set a new value at selected index. More intuitive syntax with assignment operator := is available in POOL.

Example 1:

make "a {10 11 12}
print :a
print item 2 :a
print :a,2

print item 2 "word
print "word,2

Output:

{10 11 12}
11
11
o
o

Example 2:

make "a {1 2 3}
:a,2 := "x
print :a

Output:

{1 x 3}

See also:

setitem - set element at index

Array
List
Word

Table of Content