Project

General

Profile

Up

tupleGet

Retrieve the value of an element of a tuple from its position.

If the position is out of range, the function will return nil.

Prototype :

fun [u0 I u1] u1

  • u0 : a tuple. If this argument is not a tuple, the application can have an undefined behavior.
  • I : a position. If the position is out of range, nil will be returned
  • u1 : must be always nil

Return : u1 the value or nil if error

See also :

tupleSet

tupleSize

Example :

fun main ()=
	_showconsole;
	_fooS tupleGet [2 20.5 "Bob"] 2 nil;	// Bob
	0;;

Do a recursive process with a tuple. Note that for the first call to displayTuple, 'value' will be nil because the given position is out of range. But the function continues and retrieves the good values. So, it is better to call directly the function with displayTuple tuple tupleSize tuple - 1; instead.

fun displayTuple (array, n)=
	if n < 0 then
		0
	else
	let tupleGet array n nil -> value in
	(
		// do something with each 'value'
		displayTuple a n-1
	);;

fun main ()=
	_showconsole;
	let ["France" 21/2 0-1 _GETscreenSize] -> tuple in	// any tuple
	displayTuple tuple tupleSize tuple;

Note