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

13 LES LISTES TYPEES MLIST
13 THE TYPED LISTS MLIST
13.2 Champs d'une liste / Fields of a list
Version 2.1.2 du 26 janvier 2005 / Version 2.1.2, 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 13.3 / Next section 13.3

a

b
definefields (mlist)
c
null (mlist)
d
setfield (mlist)
e
getfield (mlist)

Les opérations générales sur les champs des listes de type list s'appliquent également aux champs des listes de type mlist.
The general operations on fields of lists if type list also apply to fields of lists of type mlist.

Cependant, il est fortement recommandé de ne pas utiliser la notation indice de list, en particulier sur le premier champ de la liste, mais les noms définis dans la déclaration de la liste mlist..
However, it is strongly recomended to do not use the index notation of list, in particlar on the first field of the list, but the names defined in the declaration of the list mlist.

// PROGRAMME SPAS130201 : mlist
m=mlist(["nom";"ch1";"ch2";"ch3"],1.1, 1.2, 1.3);
m("ch2"),
m.ch2,
m(3),


Ch13Sc02-Fig01

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 SPAS130202 - mlist  definefields
mm=mlist(["nom";"ch1";"ch2";"ch3"]);
mm.ch3="toto";
v = definedfields (mm),


Ch13Sc02-Fig02

La fonction null rend un champ indéfini, en fait lui affecte la variable vide []. Ne pas l'appliquer au premier champ !
The function null suppresses the value of a field, in fact affects the null variable [] to the field. Do not apply it to the first field !

// PROGRAMME SPAS130203 - mlist  null
mm=mlist(["nom";"ch1";"ch2";"ch3"], 1, 10, 3.50);
mm.ch1,
mm.ch1 = null;
mm.ch1,
mm(1) = null;
mm.ch1,


Ch13Sc02-Fig03

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 SPAS130204 - mlist  affectation setfield
mm=mlist(["nom";"ch1";"ch2";"ch3"],1, 2, 3);
v = int32(257);
setfield ("ch3",v,mm)
mm.ch3,

Ch13Sc02-Fig04

La procédure getfield extrait  plusieurs champs d'une liste.
The procedure getfield  extracts several fields from a list.

// PROGRAMME SPAS130205 - mlist  extraction multiple getfield
mm=mlist(["nom";"ch1";"ch2";"ch3"],4, 5, 7);
[a, b] = getfield (["ch3", "ch1"],mm),

Ch13Sc02-Fig05

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 13.3 / Next section 13.3