* [#8059](https://bugzilla.scilab.org/8059): A local `.wgetrc` config file could make troubles in `atomsDownload`.
* [#9909](https://bugzilla.scilab.org/9909): In the help browser, add a way to open the online version of the current page.
* [#12889](https://bugzilla.scilab.org/12889): In the help browser, add a menu allowing to select the language of help pages, regardless of the language of the session.
+* [#14873](https://bugzilla.scilab.org/14873): `setfield` page: The output and the 6.0 history were documented only on the en_US version. The input was wrongly restricted to matrices, while any Scilab object is acceptable. The specific role of `setfield` for mlists was not really described nor illustrated. The example did not include any call to setfield.
* [#15839](https://bugzilla.scilab.org/15839): `gsort`: the only sparse possible input were real or complex vectors, and only with the `g` method.
* [#15842](https://bugzilla.scilab.org/15842): `unique` could not process 2D sparse matrices.
* [#16106](https://bugzilla.scilab.org/16106): Xcos sciblk4 user-defined blocks did not handle opar and odstate/oz correctly.
<!--
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
* Copyright (C) 2006-2008 - INRIA
- *
* Copyright (C) 2012 - 2016 - Scilab Enterprises
+ * Copyright (C) 2020 - Samuel GOUGEON
*
* This file is hereby licensed under the terms of the GNU GPL v2.0,
* pursuant to article 5.3.4 of the CeCILL v.2.1.
* along with this program.
*
-->
-<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="en" xml:id="setfield">
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:svg="http://www.w3.org/2000/svg" xmlns:db="http://docbook.org/ns/docbook"
+ xmlns:scilab="http://www.scilab.org" xml:lang="en" xml:id="setfield">
<refnamediv>
<refname>setfield</refname>
- <refpurpose>list field insertion</refpurpose>
+ <refpurpose>change the value of an element of a mlist, tlist or list</refpurpose>
</refnamediv>
<refsynopsisdiv>
<title>Syntax</title>
- <synopsis>a = setfield(i, x, l)</synopsis>
+ <synopsis>uL = setfield(a, v, L)</synopsis>
</refsynopsisdiv>
<refsection>
<title>Arguments</title>
<variablelist>
<varlistentry>
- <term>x</term>
+ <term>L</term>
<listitem>
- <para>a matrix of any possible types.</para>
+ a <literal>list</literal>, <literal>tlist</literal> or <literal>mlist</literal>
+ list: the list whose component must be changed.
+ <para/>
</listitem>
</varlistentry>
<varlistentry>
- <term>l</term>
+ <term>a</term>
<listitem>
- <para>
- a <literal>list</literal>, <literal>tlist</literal> or <literal>mlist</literal> variable.
- </para>
+ Address of the component to change. It can be either its field name
+ specified as a string, or its index specified as a positive integer.
+ See <link linkend="insertion">insertion</link> for more details.
+ <para/>
</listitem>
</varlistentry>
<varlistentry>
- <term>i</term>
+ <term>v</term>
<listitem>
- <para>
- a field index, see <link linkend="insertion">insertion</link> for more details.
- </para>
+ Any Scilab object: the value to assign.
+ <para/>
</listitem>
</varlistentry>
<varlistentry>
- <term>a</term>
+ <term>uL</term>
<listitem>
- <para>
- Updated variable.
- </para>
+ The updated list.
+ <para/>
</listitem>
</varlistentry>
</variablelist>
<refsection>
<title>Description</title>
<para>
- This function is an equivalent of <code>l(i)=x</code> syntax for field
- extraction with the only difference that it also applies to
- <literal>mlist</literal> objects.
+ <literal>L=setfield(a,v,L)</literal> addresses and changes the
+ i<superscript>th</superscript> element of a list, in a unified way
+ over lists, tlists and mlists.
+ </para>
+ <para>
+ For simple lists and for tlists, <literal>L=setfield(a,v,L)</literal>
+ is equivalent to <literal>L(a)=v</literal>, that is simpler and should be preferred.
+ The same stands for any mlist if the address <varname>a</varname> is a
+ field's name.
+ </para>
+ <para>
+ However, for any mlist L, if <literal>i</literal> is an index, the insertion
+ <literal>L(i)=v</literal> is not predefined, in order to let the user define
+ an overload implementing a matrix-oriented insertion, if required.
+ Yet <literal>setfield(i,v,L)</literal> is always defined, with the same meaning as
+ for other list and tlist types.
</para>
</refsection>
<refsection>
<title>Examples</title>
+ <para>
+ For a tlist, <literal>setfield(3, v, T)</literal> is equivalent to
+ <literal>T(3)=v</literal> :
+ </para>
<programlisting role="example"><![CDATA[
-l=list(1,'qwerw',%s)
-l(1)='Changed'
-l(0)='Added'
-l(6)=['one more';'added']
-l=setfield(5,"added by setfield", l)
+T = tlist(['V','a','b'], [%z (1-%z) %z^2], [%f %t %t]);
+// The insertion is predefined:
+T(3) = [%t %t %f];
+T(3)
+
+T = setfield(3, [%f %t %f], T);
+T(3)
]]></programlisting>
+ <screen><![CDATA[
+--> T = tlist(['V','a','b'], [%z (1-%z) %z^2], [%f %t %t]);
+--> // The insertion is predefined:
+--> T(3) = [%t %t %f];
+--> T(3)
+ ans =
+ T T F
+
+--> T = setfield(3, [%f %t %f], T);
+--> T(3)
+ ans =
+ F T F
+]]></screen>
+ <para>
+ For a mlist, there is no predefined indexed insertion routine, to
+ let the user define a matrix-oriented insertion overload if required.
+ </para>
+ <programlisting role="example"><![CDATA[
+M = mlist(['V','a','b'], [%z (1-%z) %z^2], [%f %t %t]);
+M.b = [%t %t %t];
+M.b // OK, while ...
+M(3) = [%f %t %f]; // => error
+
+// But a raw direct insertion with setfield() is always possible:
+M = setfield(3, [%t %f %t], M);
+getfield(3, M)
+ ]]></programlisting>
+ <screen><![CDATA[
+--> M = mlist(['V','a','b'], [%z (1-%z) %z^2], [%f %t %t]);
+--> M.b = [%t %t %t];
+--> M.b // OK, while ...
+ ans =
+ T T T
+
+--> M(3) = [%f %t %f]; // => error
+Function not defined for given argument type(s),
+ check arguments or define function %b_i_V for overloading.
+
+--> // But a raw direct insertion with setfield() is always possible:
+--> M = setfield(3, [%t %f %t], M);
+--> getfield(3, M)
+ ans =
+ T F T
+]]></screen>
</refsection>
<refsection role="see also">
<title>See also</title>
<member>
<link linkend="insertion">insertion</link>
</member>
+ <member>
+ <link linkend="getfield">getfield</link>
+ </member>
</simplelist>
</refsection>
<refsection>
<revision>
<revnumber>6.0.0</revnumber>
<revdescription>
- setfield returns variable updated instead of change it "in place".
+ <itemizedlist>
+ <listitem>
+ The updated list is now returned, instead of being changed "in place".
+ </listitem>
+ <listitem>
+ setfield() can no longer be used for cells arrays.
+ </listitem>
+ </itemizedlist>
</revdescription>
</revision>
</revhistory>
<?xml version="1.0" encoding="UTF-8"?>
-<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="fr" xml:id="setfield">
+<!--
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2006-2008 - INRIA
+ * Copyright (C) 2012 - 2016 - Scilab Enterprises
+ * Copyright (C) 2020 - Samuel GOUGEON
+ *
+ * This file is hereby licensed under the terms of the GNU GPL v2.0,
+ * pursuant to article 5.3.4 of the CeCILL v.2.1.
+ * This file was originally licensed under the terms of the CeCILL v2.1,
+ * and continues to be available under such terms.
+ * For more information, see the COPYING file which you should have received
+ * along with this program.
+ *
+ -->
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:svg="http://www.w3.org/2000/svg" xmlns:db="http://docbook.org/ns/docbook"
+ xmlns:scilab="http://www.scilab.org" xml:lang="fr" xml:id="setfield">
<refnamediv>
<refname>setfield</refname>
- <refpurpose>insertion dans un champ d'une liste </refpurpose>
+ <refpurpose>modifie la valeur d'un élément d'une mlist, tlist ou list</refpurpose>
</refnamediv>
<refsynopsisdiv>
<title>Séquence d'appel</title>
- <synopsis>setfield(i,x,l)</synopsis>
+ <synopsis>uL = setfield(a, v, L)</synopsis>
</refsynopsisdiv>
<refsection>
- <title>Paramètres</title>
+ <title>Arguments</title>
<variablelist>
<varlistentry>
- <term>x </term>
+ <term>L</term>
<listitem>
- <para>matrice de tout type
- </para>
+ liste de type <literal>list</literal>, <literal>tlist</literal> ou
+ <literal>mlist</literal>, dont un élement doit être modifié.
+ <para/>
</listitem>
</varlistentry>
<varlistentry>
- <term>l </term>
+ <term>a</term>
<listitem>
- <para>variable de type list, tlist ou mlist
- </para>
+ Adresse de l'élément de liste à modifier. Elle peut être soit un mot texte
+ spécifiant un nom de champ, soit un entier positif indiquant le n°
+ de l'élément dans la liste.
+ Voir <link linkend="insertion">insertion</link> pour plus de détails.
+ <para/>
</listitem>
</varlistentry>
<varlistentry>
- <term>i </term>
+ <term>v</term>
<listitem>
- <para>
- indice de champ, voir <literal>insertion</literal> pour plus de détails.
- </para>
+ Tout objet Scilab : la valeur à affecter à l'élément.
+ <para/>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>uL</term>
+ <listitem>
+ Liste modifiée.
+ <para/>
</listitem>
</varlistentry>
</variablelist>
<refsection>
<title>Description</title>
<para>
- Cette fonction est équivalente à la syntaxe <literal>l(i)=x</literal> pour l'extraction avec la seule différence qu'elle s'applique aussi aux objets de type <literal>mlist</literal>.
+ <literal>L=setfield(a,v,L)</literal> adresse et modifie le
+ i<superscript>ème</superscript> élément d'une liste, selon une
+ syntaxe identique pour tous les types list, tlist et mlist
+ disponibles en Scilab.
+ </para>
+ <para>
+ Pour des simples list et pour des mlist, <literal>L=setfield(a,v,L)</literal>
+ est équivalent à <literal>L(a)=v</literal>, qui est plus simple et préférable.
+ L'équivalence tient aussi pour toute mlist si l'adresse <varname>a</varname>
+ est le nom d'un champ.
+ </para>
+ <para>
+ En revanche, pour toute mlist <varname>L</varname>, si <literal>i</literal>
+ est un n°, <literal>L(i)=v</literal> adresse le i<superscript>ème</superscript>
+ élément de <varname>L</varname> considérée comme un vecteur, au lieu
+ du i<superscript>ème</superscript> élément tel que déclaré dans la
+ définition initiale <literal>mlist(c1,c2,c3...)</literal>.
+ <literal>setfield(i,v,L)</literal> aura alors le même sens que pour les
+ autres types de listes.
</para>
</refsection>
<refsection>
<title>Exemples</title>
+ <para>
+ Pour une tlist, <literal>setfield(3, v, T)</literal> équivaut à
+ <literal>T(3)=v</literal> :
+ </para>
+ <programlisting role="example"><![CDATA[
+T = tlist(['V','a','b'], [%z (1-%z) %z^2], [%f %t %t]);
+// L'insertion est prédéfinie :
+T(3) = [%t %t %f];
+T(3)
+
+T = setfield(3, [%f %t %f], T);
+T(3)
+ ]]></programlisting>
+ <screen><![CDATA[
+--> T = tlist(['V','a','b'], [%z (1-%z) %z^2], [%f %t %t]);
+--> // L'insertion est prédéfinie :
+--> T(3) = [%t %t %f];
+--> T(3)
+ ans =
+ T T F
+
+--> T = setfield(3, [%f %t %f], T);
+--> T(3)
+ ans =
+ F T F
+]]></screen>
+ <para>
+ Pour une mlist, aucune routine d'insertion indexée n'est prédéfinie. L'utilisateur
+ est ainsi libre d'en définir une pour un adressage matriciel des données.
+ </para>
<programlisting role="example"><![CDATA[
-l=list(1,'qwerw',%s)
-l(1)='change'
-l(0)='ajoute'
-l(6)=['un de plus';'ajoute']
+M = mlist(['V','a','b'], [%z (1-%z) %z^2], [%f %t %t]);
+M.b = [%t %t %t];
+M.b // OK, alors que ...
+M(3) = [%f %t %f]; // => erreur
+
+// Une insertion directe avec setfield() est toujours possible :
+M = setfield(3, [%t %f %t], M);
+getfield(3, M)
]]></programlisting>
+ <screen><![CDATA[
+--> M = mlist(['V','a','b'], [%z (1-%z) %z^2], [%f %t %t]);
+--> M.b = [%t %t %t];
+--> M.b
+ ans =
+ T T T
+
+--> M(3) = [%t %f %t]; // => erreur
+Fonction non définie pour les types fournis.
+ vérifier les arguments ou définir la fonction %b_i_V pour la surcharge.
+
+--> // Une insertion directe avec setfield() est toujours possible :
+--> M = setfield(3, [%t %f %t], M);
+--> getfield(3, M)
+ ans =
+ T F T
+]]></screen>
</refsection>
<refsection role="see also">
<title>Voir aussi</title>
<member>
<link linkend="insertion">insertion</link>
</member>
+ <member>
+ <link linkend="getfield">getfield</link>
+ </member>
</simplelist>
</refsection>
+ <refsection>
+ <title>History</title>
+ <revhistory>
+ <revision>
+ <revnumber>6.0.0</revnumber>
+ <revdescription>
+
+ <itemizedlist>
+ <listitem>
+ La liste modifiée est désormais donnée en réponse, au lieu d'être
+ modifiée "sur place".
+ </listitem>
+ <listitem>
+ setfield() ne peut plus être utilisée pour des tableaux de cellules.
+ </listitem>
+ </itemizedlist>
+ </revdescription>
+ </revision>
+ </revhistory>
+ </refsection>
</refentry>
<!--
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
* Copyright (C) 2006-2008 - INRIA
- *
* Copyright (C) 2012 - 2016 - Scilab Enterprises
+ * Copyright (C) 2020 - Samuel GOUGEON
*
* This file is hereby licensed under the terms of the GNU GPL v2.0,
* pursuant to article 5.3.4 of the CeCILL v.2.1.
* along with this program.
*
-->
-<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="ja" xml:id="setfield">
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:svg="http://www.w3.org/2000/svg" xmlns:db="http://docbook.org/ns/docbook"
+ xmlns:scilab="http://www.scilab.org" xml:lang="ja" xml:id="setfield">
<refnamediv>
<refname>setfield</refname>
- <refpurpose>list フィールドの挿入</refpurpose>
+ <refpurpose>mlist, tlist, またはlistの要素の値を変更する</refpurpose>
</refnamediv>
<refsynopsisdiv>
<title>呼び出し手順</title>
- <synopsis>setfield(i,x,l)</synopsis>
+ <synopsis>uL = setfield(a, v, L)</synopsis>
</refsynopsisdiv>
<refsection>
<title>パラメータ</title>
<variablelist>
<varlistentry>
- <term>x</term>
+ <term>L</term>
+ <listitem>
+ <literal>list</literal>, <literal>tlist</literal>,
+ または<literal>mlist</literal>リスト:コンポーネントを変更する必要があるリスト.
+ <para/>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>a</term>
<listitem>
- <para>任意の型の行列</para>
+ 変更するコンポーネントのアドレス. 文字列として指定されたフィールド名,
+ または正の整数として指定されたインデックスのいずれかになります.
+ 詳細については, <link linkend="insertion">insertion</link>をご覧ください.
+ <para/>
</listitem>
</varlistentry>
<varlistentry>
- <term>l</term>
+ <term>v</term>
<listitem>
- <para>list, tlist または mlist 変数</para>
+ 任意のScilabオブジェクト:割り当てる値
+ <para/>
</listitem>
</varlistentry>
<varlistentry>
- <term>i</term>
+ <term>uL</term>
<listitem>
- <para>フィールド添え字, 詳細は insertion 参照.</para>
+ 更新されたリスト
+ <para/>
</listitem>
</varlistentry>
</variablelist>
<refsection>
<title>説明</title>
<para>
- この関数は,フィールド展開を行う<literal>l(i)=x</literal>構文と等価ですが,
- 唯一の差異は,<literal>mlist</literal>オブジェクトにも適用可能なことです.
+ <literal>L=setfield(a,v,L)</literal> addresses and changes the
+ i<superscript>th</superscript> element of a list, in a unified way
+ over lists, tlists and mlists.
+ </para>
+ <para>
+ For simple lists and for tlists, <literal>L=setfield(a,v,L)</literal>
+ is equivalent to <literal>L(a)=v</literal>, that is simpler and should be preferred.
+ The same stands for any mlist if the address <varname>a</varname> is a
+ field's name.
+ </para>
+ <para>
+ However, for any mlist L, if <literal>i</literal> is an index, the insertion
+ <literal>L(i)=v</literal> is not predefined, in order to let the user define
+ an overload implementing a matrix-oriented insertion, if required.
+ Yet <literal>setfield(i,v,L)</literal> is always defined, with the same meaning as
+ for other list and tlist types.
</para>
</refsection>
<refsection>
<title>例</title>
+ <para>
+ For a tlist, <literal>setfield(3, v, T)</literal> is equivalent to
+ <literal>T(3)=v</literal> :
+ </para>
+ <programlisting role="example"><![CDATA[
+T = tlist(['V','a','b'], [%z (1-%z) %z^2], [%f %t %t]);
+// The insertion is predefined:
+T(3) = [%t %t %f];
+T(3)
+
+T = setfield(3, [%f %t %f], T);
+T(3)
+ ]]></programlisting>
+ <screen><![CDATA[
+--> T = tlist(['V','a','b'], [%z (1-%z) %z^2], [%f %t %t]);
+--> // The insertion is predefined:
+--> T(3) = [%t %t %f];
+--> T(3)
+ ans =
+ T T F
+
+--> T = setfield(3, [%f %t %f], T);
+--> T(3)
+ ans =
+ F T F
+]]></screen>
+ <para>
+ For a mlist, there is no predefined indexed insertion routine, to let
+ the user define a matrix-oriented insertion overload if required.
+ </para>
<programlisting role="example"><![CDATA[
-l=list(1,'qwerw',%s)
-l(1)='Changed'
-l(0)='Added'
-l(6)=['one more';'added']
+M = mlist(['V','a','b'], [%z (1-%z) %z^2], [%f %t %t]);
+M.b = [%t %t %t];
+M.b // OK, while ...
+M(3) = [%f %t %f]; // => error
+
+// But a raw direct insertion with setfield() is always possible:
+M = setfield(3, [%t %f %t], M);
+getfield(3, M)
]]></programlisting>
+ <screen><![CDATA[
+--> M = mlist(['V','a','b'], [%z (1-%z) %z^2], [%f %t %t]);
+--> M.b = [%t %t %t];
+--> M.b // OK, while ...
+ ans =
+ T T T
+
+--> M(3) = [%f %t %f]; // => error
+Function not defined for given argument type(s),
+ check arguments or define function %b_i_V for overloading.
+
+--> // But a raw direct insertion with setfield() is always possible:
+--> M = setfield(3, [%t %f %t], M);
+--> getfield(3, M)
+ ans =
+ T F T
+]]></screen>
</refsection>
<refsection role="see also">
<title>参照</title>
<member>
<link linkend="insertion">insertion</link>
</member>
+ <member>
+ <link linkend="getfield">getfield</link>
+ </member>
</simplelist>
</refsection>
+ <refsection>
+ <title>履歴</title>
+ <revhistory>
+ <revision>
+ <revnumber>6.0.0</revnumber>
+ <revdescription>
+ <itemizedlist>
+ <listitem>
+ The updated list is now returned, instead of being changed "in place".
+ </listitem>
+ <listitem>
+ setfield() can no longer be used for cells arrays.
+ </listitem>
+ </itemizedlist>
+ </revdescription>
+ </revision>
+ </revhistory>
+ </refsection>
</refentry>
<!--
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
* Copyright (C) 2006-2008 - INRIA
- *
* Copyright (C) 2012 - 2016 - Scilab Enterprises
+ * Copyright (C) 2020 - Samuel GOUGEON
*
* This file is hereby licensed under the terms of the GNU GPL v2.0,
* pursuant to article 5.3.4 of the CeCILL v.2.1.
* along with this program.
*
-->
-<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns4="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="setfield" xml:lang="pt">
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns4="http://www.w3.org/1999/xhtml"
+ xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"
+ xml:id="setfield" xml:lang="pt">
<refnamediv>
<refname>setfield</refname>
- <refpurpose>inserção de campos de listas</refpurpose>
+ <refpurpose>altera o valor de um elemento de uma mlist, tlist ou list</refpurpose>
</refnamediv>
<refsynopsisdiv>
<title>Seqüência de Chamamento</title>
- <synopsis>setfield(i,x,l)</synopsis>
+ <synopsis>uL = setfield(a, v, L)</synopsis>
</refsynopsisdiv>
<refsection>
<title>Parâmetros</title>
<variablelist>
<varlistentry>
- <term>x</term>
+ <term>L</term>
+ <listitem>
+ lista do tipo <literal>list</literal>, <literal>tlist</literal> ou
+ <literal>mlist</literal> : a lista cujo componente deve ser alterado.
+ <para/>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>a</term>
<listitem>
- <para>matriz de qualquer tipo</para>
+ Endereço do componente a ser alterado. Pode ser o nome do campo
+ especificado como uma sequência, ou o índice especificado como
+ um número inteiro positivo. Veja <link linkend="inserção">inserção</link>
+ para mais detalhes.
+ <para/>
</listitem>
</varlistentry>
<varlistentry>
- <term>l</term>
+ <term>v</term>
<listitem>
- <para>lista, tlist ou mlist </para>
+ Qualquer objeto Scilab : o valor a ser atribuído.
+ <para/>
</listitem>
</varlistentry>
<varlistentry>
- <term>i</term>
+ <term>uL</term>
<listitem>
- <para>índice de campo, ver "insertion" para mais detalhes.</para>
+ A lista atualizada.
+ <para/>
</listitem>
</varlistentry>
</variablelist>
<refsection>
<title>Descrição</title>
<para>
- Esta função é equivalente à sintaxe <literal>l(i)=x</literal> spara
- inserção de campos, com a única diferença de que também se aplica a
- objetos <literal>mlist</literal>.
+ <literal>L=setfield(a,v,L)</literal> addresses and changes the
+ i<superscript>th</superscript> element of a list, in a unified way
+ over lists, tlists and mlists.
+ </para>
+ <para>
+ For simple lists and for tlists, <literal>L=setfield(a,v,L)</literal>
+ is equivalent to <literal>L(a)=v</literal>, that is simpler and should be preferred.
+ The same stands for any mlist if the address <varname>a</varname> is a
+ field's name.
+ </para>
+ <para>
+ However, for any mlist L, if <literal>i</literal> is an index, the insertion
+ <literal>L(i)=v</literal> is not predefined, in order to let the user define
+ an overload implementing a matrix-oriented insertion, if required.
+ Yet <literal>setfield(i,v,L)</literal> is always defined, with the same meaning as
+ for other list and tlist types.
</para>
</refsection>
<refsection>
<title>Exemplos</title>
+ <para>
+ For a tlist, <literal>setfield(3, v, T)</literal> is equivalent to
+ <literal>T(3)=v</literal> :
+ </para>
+ <programlisting role="example"><![CDATA[
+T = tlist(['V','a','b'], [%z (1-%z) %z^2], [%f %t %t]);
+// The insertion is predefined:
+T(3) = [%t %t %f];
+T(3)
+
+T = setfield(3, [%f %t %f], T);
+T(3)
+ ]]></programlisting>
+ <screen><![CDATA[
+--> T = tlist(['V','a','b'], [%z (1-%z) %z^2], [%f %t %t]);
+--> // The insertion is predefined:
+--> T(3) = [%t %t %f];
+--> T(3)
+ ans =
+ T T F
+
+--> T = setfield(3, [%f %t %f], T);
+--> T(3)
+ ans =
+ F T F
+]]></screen>
+ <para>
+ For a mlist, there is no predefined indexed insertion routine, to let
+ the user define a matrix-oriented insertion overload if required.
+ </para>
<programlisting role="example"><![CDATA[
-l=list(1,'qwerw',%s)
-l(1)='Modificado'
-l(0)='Adicionado'
-l(6)=['mais um';'adicionado']
+M = mlist(['V','a','b'], [%z (1-%z) %z^2], [%f %t %t]);
+M.b = [%t %t %t];
+M.b // OK, while ...
+M(3) = [%f %t %f]; // => error
+
+// But a raw direct insertion with setfield() is always possible:
+M = setfield(3, [%t %f %t], M);
+getfield(3, M)
]]></programlisting>
+ <screen><![CDATA[
+--> M = mlist(['V','a','b'], [%z (1-%z) %z^2], [%f %t %t]);
+--> M.b = [%t %t %t];
+--> M.b // OK, while ...
+ ans =
+ T T T
+
+--> M(3) = [%f %t %f]; // => error
+Function not defined for given argument type(s),
+ check arguments or define function %b_i_V for overloading.
+
+--> // But a raw direct insertion with setfield() is always possible:
+--> M = setfield(3, [%t %f %t], M);
+--> getfield(3, M)
+ ans =
+ T F T
+]]></screen>
</refsection>
<refsection role="see also">
<title>Ver Também</title>
<member>
<link linkend="insertion">insertion</link>
</member>
+ <member>
+ <link linkend="getfield">getfield</link>
+ </member>
</simplelist>
</refsection>
+ <refsection>
+ <title>Histórico</title>
+ <revhistory>
+ <revision>
+ <revnumber>6.0.0</revnumber>
+ <revdescription>
+ <itemizedlist>
+ <listitem>
+ The updated list is now returned, instead of being changed "in place".
+ </listitem>
+ <listitem>
+ setfield() can no longer be used for cells arrays.
+ </listitem>
+ </itemizedlist>
+ </revdescription>
+ </revision>
+ </revhistory>
+ </refsection>
</refentry>
<!--
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
* Copyright (C) 2006-2008 - INRIA
- *
* Copyright (C) 2012 - 2016 - Scilab Enterprises
+ * Copyright (C) 2020 - Samuel GOUGEON
*
* This file is hereby licensed under the terms of the GNU GPL v2.0,
* pursuant to article 5.3.4 of the CeCILL v.2.1.
* along with this program.
*
-->
-<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="ru" xml:id="setfield">
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:svg="http://www.w3.org/2000/svg" xmlns:db="http://docbook.org/ns/docbook"
+ xmlns:scilab="http://www.scilab.org" xml:lang="ru" xml:id="setfield">
<refnamediv>
<refname>setfield</refname>
- <refpurpose>внесение поля списка</refpurpose>
+ <refpurpose>изменение значения элемента списка типа mlist, tlist или list</refpurpose>
</refnamediv>
<refsynopsisdiv>
<title>Синтаксис</title>
- <synopsis>setfield(i, x, l)</synopsis>
+ <synopsis>uL = setfield(a, v, L)</synopsis>
</refsynopsisdiv>
<refsection>
<title>Аргументы</title>
<variablelist>
<varlistentry>
- <term>x</term>
+ <term>L</term>
<listitem>
- <para>матрица всевозможного типа.</para>
+ список типа <literal>list</literal>, <literal>tlist</literal> или
+ <literal>mlist</literal>: список, в котором требуется изменить элемент.
+ <para/>
</listitem>
</varlistentry>
<varlistentry>
- <term>l</term>
+ <term>a</term>
<listitem>
- <para>
- переменная типа <literal>list</literal>, <literal>tlist</literal> или <literal>mlist</literal>.
- </para>
+ адрес элемента, который нужно изменить. Это может быть или его имя
+ поля, указанного в виде строки, либо его индекс, указанный в виде
+ положительного целого числа. См. подробности в <link linkend="insertion">вставке</link>.
+ <para/>
</listitem>
</varlistentry>
<varlistentry>
- <term>i</term>
+ <term>v</term>
<listitem>
- <para>
- индекс поля, см. справку по <link linkend="insertion">вставке</link>.
- </para>
+ любой объект Scilab: значение для присвоения.
+ <para/>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>uL</term>
+ <listitem>
+ Обновлённый список.
+ <para/>
</listitem>
</varlistentry>
</variablelist>
<refsection>
<title>Описание</title>
<para>
- Эта функция является эквивалентом синтаксиса <code>l(i)=x</code>
- для вставки поля с той лишь разницей, что она также применима к объектам <literal>mlist</literal>.
+ <literal>L=setfield(a,v,L)</literal> адресует и изменяет
+ i<superscript>й</superscript> элемент списка унифицированным образом
+ среди списков типа list, tlist и mlist.
+ </para>
+ <para>
+ Для простых списков (list) и для типизированных списков (tlist),
+ <literal>L=setfield(a,v,L)</literal> эквивалентно <literal>L(a)=v</literal>,
+ то есть проще и должно быть предпочтительнее. Аналогично для любого
+ матричноориентированного списка (mlist), если адрес <varname>a</varname>
+ является именем поля.
+ </para>
+ <para>
+ Тем не менее, для любого матричноориентированного списка
+ <varname>L</varname>, если <literal>i</literal> является индексом, то
+ вставка <literal>L(i)=v</literal> не предопределена, для того, чтобы
+ позволить пользователю определить перегрузку, реализующую
+ матричноориентированную вставку, если требуется. Вот
+ <literal>setfield(i,v,L)</literal> всегда определена, с тем же смыслом,
+ что и для других списков типа list и tlist.
</para>
</refsection>
<refsection>
<title>Примеры</title>
+ <para>
+ Для списка типа tlist, <literal>setfield(3, v, T)</literal> эквивалентно
+ <literal>T(3)=v</literal> :
+ </para>
<programlisting role="example"><![CDATA[
-l=list(1,'qwerw',%s)
-l(1)='Изменён'
-l(0)='Добавлен'
-l(6)=['ещё один';'добавлен']
+T = tlist(['V','a','b'], [%z (1-%z) %z^2], [%f %t %t]);
+// Вставка предопределена:
+T(3) = [%t %t %f];
+T(3)
+
+T = setfield(3, [%f %t %f], T);
+T(3)
]]></programlisting>
+ <screen><![CDATA[
+--> T = tlist(['V','a','b'], [%z (1-%z) %z^2], [%f %t %t]);
+--> // Вставка предопределена:
+--> T(3) = [%t %t %f];
+--> T(3)
+ ans =
+ T T F
+
+--> T = setfield(3, [%f %t %f], T);
+--> T(3)
+ ans =
+ F T F
+]]></screen>
+ <para>
+ Для списка типа mlist, нет процедуры предопределённой индексированной
+ вставки, чтобы позволить пользователю определить перегрузку
+ матричноориентированной вставки, если потребуется.
+ </para>
+ <programlisting role="example"><![CDATA[
+M = mlist(['V','a','b'], [%z (1-%z) %z^2], [%f %t %t]);
+M.b = [%t %t %t];
+M.b // OK, пока ...
+M(3) = [%f %t %f]; // => error
+
+// Но необработанная прямая вставка с setfield() всегда возможна:
+M = setfield(3, [%t %f %t], M);
+getfield(3, M)
+ ]]></programlisting>
+ <screen><![CDATA[
+--> M = mlist(['V','a','b'], [%z (1-%z) %z^2], [%f %t %t]);
+--> M.b = [%t %t %t];
+--> M.b // OK, пока ...
+ ans =
+ T T T
+
+--> M(3) = [%f %t %f]; // => error
+Function not defined for given argument type(s),
+ check arguments or define function %b_i_V for overloading.
+
+--> // Но необработанная прямая вставка с setfield() всегда возможна:
+--> M = setfield(3, [%t %f %t], M);
+--> getfield(3, M)
+ ans =
+ T F T
+]]></screen>
</refsection>
<refsection role="see also">
<title>Смотрите также</title>
<member>
<link linkend="insertion">вставка</link>
</member>
+ <member>
+ <link linkend="getfield">getfield</link>
+ </member>
</simplelist>
</refsection>
+ <refsection>
+ <title>История</title>
+ <revhistory>
+ <revision>
+ <revnumber>6.0.0</revnumber>
+ <revdescription>
+ <itemizedlist>
+ <listitem>
+ Теперь возвращается обновлённый список вместо изменения
+ "на месте".
+ </listitem>
+ <listitem>
+ setfield() больше не может использоваться для cell-массивов.
+ </listitem>
+ </itemizedlist>
+ </revdescription>
+ </revision>
+ </revhistory>
+ </refsection>
</refentry>
-