Help Contents / Data Structure Primitives / Selectors / Item

Itemoutputitem Item index athing outputitem thingname.index outputitem tablename'index 

if athing is a word, outputs the "index"th character of the word.  If athing is a list, outputs the "index"th member of the list.  If athing is an array, outputs the "index"th item of the array.  Index starts at 1 for words and lists; the starting index of an array is specified when the array is created. 

If index is a list and athing is a list, or if index is an Array and athing is an Array, or if index is an IntArray and athing is an FloatArray, then a list of the items indexed by the index list elements is the result of Item. This is nice for permutations, as seen in the example. 

The dot and singlequote notation is experimental, but very comfortable. 

Examples: 

	w="hallo 
	show Item 2 w		;a 
	w.2		;a 

	l=[a b c] 
	show l.3		;c 

	a=array 4 
	show a.1		;[] 

	l=[[a b][c d][e f]] 
	show (l.3).1		;e 

	t=table 5 
	t'a=1234 
	show item "a t		;1234 
	show t'a		;1234 

	Item [1 3 6][10 20 30 40 50 60]		;[10 30 60] 
	Item IntArray [1 3 6] FloatArray[10 20 30 40 50 60]	;{10 30 60}  ;-) 
	Item {1 3 6}{10 20 30 40 50 60}		;{10 30 60}  ;-) 

	a={1 2 3 4 5 6} 
	p={6 3 4 5 1 2} 
	repeat 6 [a=Item p a  pr a] 
	{6 3 4 5 1 2} 
	{2 4 5 1 6 3} 
	{3 5 1 6 2 4} 
	{4 1 6 2 3 5} 
	{5 6 2 3 4 1} 
	{1 2 3 4 5 6} 


previous: butLast	next: pick
