Project

General

Profile

Up

tabExtractL

Extract values from an other array in a new array.

Prototype :

fun [tab u0 [I r1]] tab u0

  • tab u0 : an array.
  • [I r1] : a list of index to do the extraction. If an index is out of range, the value in the new array will be nil.

Return : tab u0 the new tab or nil if error

See also :

tabExtract

forTab

Example :

The order of the list is important. A different one will return a different array.

fun main ()=
	_showconsole;
	let tabRange 6 0 2 -> array in
	let tabExtractL array 1::2::4::7::nil -> subarray in	// a new array from 'array'
	(
	_fooIdTab array;		// 0:2:4:6:8:10:
	_fooIdTab subarray;	// 2:4:8:-1:	// the last element is nil (-1) because there is not the index 7 in 'array'
	_fooId sizetab subarray;	// 4  the size of subarray is confirmed
	set subarray.3 = 25;	// the last element is set
	_fooIdTab subarray;	// 2:4:8:25:
	0;;

Note

The first element has always the index 0.