<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Monospaced;
panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
color:black;
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
{mso-style-priority:99;
mso-style-link:"Texte brut Car";
margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
color:black;
mso-fareast-language:EN-US;}
p
{mso-style-priority:99;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman",serif;
color:black;}
pre
{mso-style-priority:99;
mso-style-link:"Préformaté HTML Car";
margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";
color:black;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman",serif;
color:black;}
span.PrformatHTMLCar
{mso-style-name:"Préformaté HTML Car";
mso-style-priority:99;
mso-style-link:"Préformaté HTML";
font-family:"Courier New";
mso-fareast-language:FR;}
span.TextebrutCar
{mso-style-name:"Texte brut Car";
mso-style-priority:99;
mso-style-link:"Texte brut";
font-family:"Calibri",sans-serif;}
span.EmailStyle23
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor="white" lang="FR" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:#1F497D">Merci de toutes ces réponses !<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span style="color:windowtext;mso-fareast-language:FR">De :</span></b><span style="color:windowtext;mso-fareast-language:FR"> users-fr <users-fr-bounces@lists.scilab.org>
<b>De la part de</b> Samuel Gougeon<br>
<b>Envoyé :</b> mardi 26 mai 2020 15:51<br>
<b>À :</b> users-fr@lists.scilab.org<br>
<b>Objet :</b> Re: [Users-fr] Un problème de liste<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Bonjour,<span style="font-size:12.0pt;mso-fareast-language:FR"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Le 26/05/2020 à 12:23, AUZANNEAU Fabrice a écrit :<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoPlainText">Bonjour<o:p></o:p></p>
<p class="MsoPlainText">J’utilise des listes dans un code Scilab et je rencontre un problème pour les modifier dans une fonction. Un exemple simple :<o:p></o:p></p>
<p class="MsoPlainText"> <o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;mso-fareast-language:FR">a
</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;color:#5C5C5C;mso-fareast-language:FR">=</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;mso-fareast-language:FR">
</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;color:#32B9B9;mso-fareast-language:FR">list</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;color:#4A55DB;mso-fareast-language:FR">()</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;mso-fareast-language:FR"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;color:#B01813;mso-fareast-language:FR">function</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;mso-fareast-language:FR">
<u>test</u></span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;color:#4A55DB;mso-fareast-language:FR">()</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;mso-fareast-language:FR"> a</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;color:#4A55DB;mso-fareast-language:FR">(</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;color:rosybrown;mso-fareast-language:FR">2</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;color:#4A55DB;mso-fareast-language:FR">)</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;mso-fareast-language:FR">
</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;color:#5C5C5C;mso-fareast-language:FR">=</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;mso-fareast-language:FR">
</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;color:#4A55DB;mso-fareast-language:FR">[</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;color:rosybrown;mso-fareast-language:FR">3</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;mso-fareast-language:FR">,</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;color:rosybrown;mso-fareast-language:FR">4</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;color:#4A55DB;mso-fareast-language:FR">]</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;color:#B01813;mso-fareast-language:FR">endfunction</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;mso-fareast-language:FR"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;mso-fareast-language:FR">a</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;color:#4A55DB;mso-fareast-language:FR">(</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;color:rosybrown;mso-fareast-language:FR">1</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;color:#4A55DB;mso-fareast-language:FR">)</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;mso-fareast-language:FR">
</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;color:#5C5C5C;mso-fareast-language:FR">=</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;mso-fareast-language:FR">
</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;color:#4A55DB;mso-fareast-language:FR">[</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;color:rosybrown;mso-fareast-language:FR">1</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;mso-fareast-language:FR">,</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;color:rosybrown;mso-fareast-language:FR">2</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;mso-fareast-language:FR">,</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;color:rosybrown;mso-fareast-language:FR">4</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;color:#4A55DB;mso-fareast-language:FR">]</span><o:p></o:p></p>
<p class="MsoNormal"><u><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;mso-fareast-language:FR">test</span></u><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;color:#4A55DB;mso-fareast-language:FR">()</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;color:#32B9B9;mso-fareast-language:FR">disp</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;color:#4A55DB;mso-fareast-language:FR">(</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;mso-fareast-language:FR">a</span><span lang="EN-US" style="font-size:9.0pt;font-family:"Monospaced",serif;color:#4A55DB;mso-fareast-language:FR">)</span><o:p></o:p></p>
<p class="MsoPlainText"><span lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoPlainText">L’exécution donne ce message d’erreur :<o:p></o:p></p>
<p class="MsoPlainText">à la ligne 2 de la fonction test ( C:\Users\***\Desktop\list.sce ligne 10 )<o:p></o:p></p>
<p class="MsoPlainText">à la ligne 13 du fichier exécuté C:\Users\***\Desktop\list.sce<o:p></o:p></p>
<p class="MsoPlainText"> <o:p></o:p></p>
<p class="MsoPlainText">Sous-matrice incorrectement définie.<o:p></o:p></p>
</blockquote>
<p><o:p> </o:p></p>
<p>Pour éviter l'erreur, il faut ajouter<br>
a = a<br>
dans la fonction, juste avant a(2) = ... : le 1er adressage de a externe en lecture en crée une copie locale. C'est celle-ci qui sera modifiée par a(2) = ..., et perdue en sortie de fonction.<br>
Pour la retourner dans l'environnement sans la faire figurer en argument de sortie explicite de la fonction, utiliser<br>
a = return(a)<o:p></o:p></p>
<p>d'où : <o:p></o:p></p>
<pre><span style="font-size:9.0pt;font-family:"Monospaced",serif;color:#B01813">function</span><span style="font-size:9.0pt;font-family:"Monospaced",serif"> <u>test</u></span><span style="font-size:9.0pt;font-family:"Monospaced",serif;color:#4A55DB">()</span><span style="font-size:9.0pt;font-family:"Monospaced",serif"><o:p></o:p></span></pre>
<pre><span style="font-size:9.0pt;font-family:"Monospaced",serif"> a </span><span style="font-size:9.0pt;font-family:"Monospaced",serif;color:#5C5C5C">=</span><span style="font-size:9.0pt;font-family:"Monospaced",serif"> a<o:p></o:p></span></pre>
<pre><span style="font-size:9.0pt;font-family:"Monospaced",serif"> a</span><span style="font-size:9.0pt;font-family:"Monospaced",serif;color:#4A55DB">(</span><span style="font-size:9.0pt;font-family:"Monospaced",serif;color:rosybrown">2</span><span style="font-size:9.0pt;font-family:"Monospaced",serif;color:#4A55DB">)</span><span style="font-size:9.0pt;font-family:"Monospaced",serif"> </span><span style="font-size:9.0pt;font-family:"Monospaced",serif;color:#5C5C5C">=</span><span style="font-size:9.0pt;font-family:"Monospaced",serif"> </span><span style="font-size:9.0pt;font-family:"Monospaced",serif;color:#4A55DB">[</span><span style="font-size:9.0pt;font-family:"Monospaced",serif;color:rosybrown">3</span><span style="font-size:9.0pt;font-family:"Monospaced",serif">,</span><span style="font-size:9.0pt;font-family:"Monospaced",serif;color:rosybrown">4</span><span style="font-size:9.0pt;font-family:"Monospaced",serif;color:#4A55DB">]</span><span style="font-size:9.0pt;font-family:"Monospaced",serif"><o:p></o:p></span></pre>
<pre><span style="font-size:9.0pt;font-family:"Monospaced",serif"> a </span><span style="font-size:9.0pt;font-family:"Monospaced",serif;color:#5C5C5C">=</span><span style="font-size:9.0pt;font-family:"Monospaced",serif"> </span><span style="font-size:9.0pt;font-family:"Monospaced",serif;color:cadetblue">return</span><span style="font-size:9.0pt;font-family:"Monospaced",serif;color:#4A55DB">(</span><span style="font-size:9.0pt;font-family:"Monospaced",serif">a</span><span style="font-size:9.0pt;font-family:"Monospaced",serif;color:#4A55DB">)</span><span style="font-size:9.0pt;font-family:"Monospaced",serif"><o:p></o:p></span></pre>
<pre><span style="font-size:9.0pt;font-family:"Monospaced",serif;color:#B01813">endfunction<o:p></o:p></span></pre>
<pre><span style="font-size:9.0pt;font-family:"Monospaced",serif;color:#B01813"><o:p> </o:p></span></pre>
<p>Samuel<o:p></o:p></p>
<p><o:p> </o:p></p>
</div>
</body>
</html>