Project

General

Profile

Up

tupletotab

Create a new array from a tuple.

If the argument is not a tuple, the program can have an undefined behavior.

If the tuple contains some variables of differents types, the returned array will have the same type than the last element of the tuple but each element of the array will keep its initial type of course. See examples below.
If you are not sure of what you do, you could don't use this function.

Prototype :

fun [u0 u1] tab u1

  • u0 : a tuple
  • u1 : must be always nil

Return : tab u1 the new array or nil if error

See also :

tabtotuple

Example :

fun main ()=
	_showconsole;
	let tupletotab [2 4 1] nil -> t in
	_fooIdTab t;	// 2:4:1:
	0;;

fun main ()=
	_showconsole;
	let tupletotab [2.0 4.1 1.5] nil -> t in
	_fooFTab t;	// 2.00000:4.099999:1.500000:
	0;;

The Scol of the function displayTuple is fun [tab S] I because the type of the last initial element is a string. But each element kept its initial type : 0 is an integer, 1 is an integer too, 2 is a string.

fun displayTuple (array)=
	_fooId array.0;	// _fooId
	_fooId array.1;	// _fooId
	_fooS array.2;	// _fooS !
	0;;

fun main ()=
	_showconsole;
	let tupletotab [0 20 "Bob"] nil -> t in
	displayTuple t;
	0;;

Note