Biomodèles/Biomodels
SCILAB 3.0 PAS A PAS
SCILAB 3.0 STEP-TO-STEP

Jacques-Deric Rouault

Laboratoire de Neurobiologie de l'Apprentissage, de la Mémoire et de la Communication. CNRS UMR 8620, Bat. 446, Université Paris-Sud, F91400 Orsay

Orscilab
ORSCILAB

12 LES LISTES LIST
12 THE LISTS LIST
12.2 Champs d'une liste / Fields of a list
Version 2.1.3 du 26 janvier 2005 / Version 2.1.3, January 26th 2005
Biomodèles/Biomodels N°1 pp 0x-0y Décembre 2004 December 2004

Retour à la Table générale / Return to the General table
Index général / General index
Passage à la section suivante 12.3 / Next section 12.3

a
Agrandir (Liste)
Enlarge (List)
Undefined (Liste, List)

b
definefields
c
Empty variable
null (Liste, List)
Variable vide
[]  (Variable vide, empty variable)

d
setfield
e
Extraction de champs d'une liste
Extracting firlds from a list
[] (Liste, List)

f
: (Liste, List)
g
getfield

Il est possible d'agrandir une liste en donnant une valeur à un nouveau champ.

It is possible to extand a list in giving a value to a new field.

// PROGRAMME SPAS120201 - list 
l = list (12.5,"abc",1:3);
l(5) = 10;
l,

Ch12Sc02-Fig01

Le champ de rang 4 qui n'est pas défini est affiché comme Undefined.
The fourth field, which was not previously defined, is displayed as Undefined.

La fonction definedfields retourne dans un vecteur les rangs des champs définis de la liste.
The function definedfields returns in a vector the ranks of the fields defined.

// PROGRAMME SPAS120203 - list  definefields
l = list (12.5,"abc",1:3);
l(5) = 10;
v = definedfields (l),


Ch12Sc02-Fig02

La fonction null rend un champ indéfini, en fait lui affecte la variable vide [].
The function null suppresses the value of a field, in fact affects the null variable [] to the field.

// PROGRAMME SPAS120203 - list  null
l = list (12.5,"abc",1:10);
l(2) = null;
l,

Ch12Sc02-Fig03

Il est possible d'affecter directement une valeur d'un autre type à un champ d'une liste.
It is possible to directly affect a value of another type to
a field of a list.

// PROGRAMME SPAS120204 - list  affectation
l = list (12.5,"abc",1:5);
l(2) = int8(10);
l,

Ch12SC02-Fig04

La procédure setfield affecte une valeur à un champ d'une liste.
The procedure setfield affects a value to one field of a list.

// PROGRAMME SPAS120205 - list  affectation setfield
l = list (12.5,"abc",1:5),
v = int8(10);
setfield (2,v,l);
l,

Ch12Sc02-Fig05

Il est possible d'extraire directement plusieurs champs d'une liste.
It is possible to directly extract several
fields from a list.

// PROGRAMME SPAS120206 - list  extraction
l = list (12.5,"abc",1:5);
[a, b] =  l([3 1]),

[a, b] =  l([3 1]) est équivalent à a = l(3) et b = l(1).
[a, b] =  l([3 1]) is equivalent to a = l(3) and b = l(1).

Ch12Sc02-Fig06

Le symbole : représente tous les éléments de la liste.
The symbol : represents all the elements of the list.

// PROGRAMME SPAS120207 - list  extraction :
l = list (12.5,"abc",1:5);
[a, b, c] =  l(:),

Ch12Sc02-Fig07

La fonction getfield extrait un champ d'une liste.
The function getfield extracts one field from a list.

// PROGRAMME SPAS120208 - list  extraction getfield
l = list (12.5,"abc",1:6);
v = getfield (2,l),

Ch12Sc02-Fig08

La fonction getfield extrait également plusieurs champs d'une liste.
The function getfield also extracts several fields from a list.

// PROGRAMME SPAS120209 - list  extraction multiple getfield
l = list (12.5,"abc",1:6);
[a, b] = getfield ([2, 1],l),

Ch12Sc02-Fig09

NB : les insertions récursives directes ne sont pas traitées ici. Voir l'article insertion-affectation dans l'Help de Scilab.
Note: the direct recursive insertions are not treated here. Refer to the item insertion-affectation of the Help of Scilab.


Retour à la Table générale / Return to the General table
Index général / General index
Passage à la section suivante 12.3 / Next section 12.3