From 0dfbb0aca93714a0ac9fca34036eca3d3f1e4d5f Mon Sep 17 00:00:00 2001 From: Samuel GOUGEON Date: Sat, 4 Jul 2020 23:33:12 +0200 Subject: [PATCH] * Bug 14873 fixed [doc]: setfield page fixed updated clarified http://bugzilla.scilab.org/14873 * The output argument was documented only on en_US * The input was restricted to matrices, while any Scilab object is acceptable. * The setfield usefullness specific to mlists was not clearly described * The example had no call to setfield for fr_FR ja_JP pt_BR and ru_RU versions It did not illustrate the setfield role for mlists. * See also: + getfield * History was incompleted for en_US and missing for other languages Page overhauled (PDF): http://bugzilla.scilab.org/attachment.cgi?id=5156 Change-Id: Ia5d7dc431c332b1016604474582056dac0ff78e8 --- scilab/CHANGES.md | 1 + .../data_structures/help/en_US/setfield.xml | 130 ++++++++++++---- .../data_structures/help/fr_FR/setfield.xml | 156 +++++++++++++++++--- .../data_structures/help/ja_JP/setfield.xml | 133 +++++++++++++++-- .../data_structures/help/pt_BR/setfield.xml | 136 ++++++++++++++--- .../data_structures/help/ru_RU/setfield.xml | 143 +++++++++++++++--- 6 files changed, 599 insertions(+), 100 deletions(-) diff --git a/scilab/CHANGES.md b/scilab/CHANGES.md index 2f3fb16..c357ae2 100644 --- a/scilab/CHANGES.md +++ b/scilab/CHANGES.md @@ -273,6 +273,7 @@ Bug Fixes * [#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. diff --git a/scilab/modules/data_structures/help/en_US/setfield.xml b/scilab/modules/data_structures/help/en_US/setfield.xml index fdf8658..979eef1 100644 --- a/scilab/modules/data_structures/help/en_US/setfield.xml +++ b/scilab/modules/data_structures/help/en_US/setfield.xml @@ -2,8 +2,8 @@ - + setfield - list field insertion + change the value of an element of a mlist, tlist or list Syntax - a = setfield(i, x, l) + uL = setfield(a, v, L) Arguments - x + L - a matrix of any possible types. + a list, tlist or mlist + list: the list whose component must be changed. + - l + a - - a list, tlist or mlist variable. - + 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 insertion for more details. + - i + v - - a field index, see insertion for more details. - + Any Scilab object: the value to assign. + - a + uL - - Updated variable. - + The updated list. + @@ -60,20 +63,83 @@ Description - This function is an equivalent of l(i)=x syntax for field - extraction with the only difference that it also applies to - mlist objects. + L=setfield(a,v,L) addresses and changes the + ith element of a list, in a unified way + over lists, tlists and mlists. + + + For simple lists and for tlists, L=setfield(a,v,L) + is equivalent to L(a)=v, that is simpler and should be preferred. + The same stands for any mlist if the address a is a + field's name. + + + However, for any mlist L, if i is an index, the insertion + L(i)=v is not predefined, in order to let the user define + an overload implementing a matrix-oriented insertion, if required. + Yet setfield(i,v,L) is always defined, with the same meaning as + for other list and tlist types. Examples + + For a tlist, setfield(3, v, T) is equivalent to + T(3)=v : + + 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 +]]> + + For a mlist, there is no predefined indexed insertion routine, to + let the user define a matrix-oriented insertion overload if required. + + error + +// But a raw direct insertion with setfield() is always possible: +M = setfield(3, [%t %f %t], M); +getfield(3, M) + ]]> + 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 +]]> See also @@ -81,6 +147,9 @@ l=setfield(5,"added by setfield", l) insertion + + getfield + @@ -89,7 +158,14 @@ l=setfield(5,"added by setfield", l) 6.0.0 - setfield returns variable updated instead of change it "in place". + + + The updated list is now returned, instead of being changed "in place". + + + setfield() can no longer be used for cells arrays. + + diff --git a/scilab/modules/data_structures/help/fr_FR/setfield.xml b/scilab/modules/data_structures/help/fr_FR/setfield.xml index fad84d8..b8cf546 100644 --- a/scilab/modules/data_structures/help/fr_FR/setfield.xml +++ b/scilab/modules/data_structures/help/fr_FR/setfield.xml @@ -1,36 +1,62 @@ - + + setfield - insertion dans un champ d'une liste + modifie la valeur d'un élément d'une mlist, tlist ou list Séquence d'appel - setfield(i,x,l) + uL = setfield(a, v, L) - Paramètres + Arguments - x + L - matrice de tout type - + liste de type list, tlist ou + mlist, dont un élement doit être modifié. + - l + a - variable de type list, tlist ou mlist - + 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 insertion pour plus de détails. + - i + v - - indice de champ, voir insertion pour plus de détails. - + Tout objet Scilab : la valeur à affecter à l'élément. + + + + + uL + + Liste modifiée. + @@ -38,17 +64,86 @@ Description - Cette fonction est équivalente à la syntaxe l(i)=x pour l'extraction avec la seule différence qu'elle s'applique aussi aux objets de type mlist. + L=setfield(a,v,L) adresse et modifie le + ième élément d'une liste, selon une + syntaxe identique pour tous les types list, tlist et mlist + disponibles en Scilab. + + + Pour des simples list et pour des mlist, L=setfield(a,v,L) + est équivalent à L(a)=v, qui est plus simple et préférable. + L'équivalence tient aussi pour toute mlist si l'adresse a + est le nom d'un champ. + + + En revanche, pour toute mlist L, si i + est un n°, L(i)=v adresse le ième + élément de L considérée comme un vecteur, au lieu + du ième élément tel que déclaré dans la + définition initiale mlist(c1,c2,c3...). + setfield(i,v,L) aura alors le même sens que pour les + autres types de listes. Exemples + + Pour une tlist, setfield(3, v, T) équivaut à + T(3)=v : + + + 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 +]]> + + 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. + erreur + +// Une insertion directe avec setfield() est toujours possible : +M = setfield(3, [%t %f %t], M); +getfield(3, M) ]]> + 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 +]]> Voir aussi @@ -56,6 +151,29 @@ l(6)=['un de plus';'ajoute'] insertion + + getfield + + + History + + + 6.0.0 + + + + + La liste modifiée est désormais donnée en réponse, au lieu d'être + modifiée "sur place". + + + setfield() ne peut plus être utilisée pour des tableaux de cellules. + + + + + + diff --git a/scilab/modules/data_structures/help/ja_JP/setfield.xml b/scilab/modules/data_structures/help/ja_JP/setfield.xml index 34fcfd9..f99b5c9 100644 --- a/scilab/modules/data_structures/help/ja_JP/setfield.xml +++ b/scilab/modules/data_structures/help/ja_JP/setfield.xml @@ -2,8 +2,8 @@ - + setfield - list フィールドの挿入 + mlist, tlist, またはlistの要素の値を変更する 呼び出し手順 - setfield(i,x,l) + uL = setfield(a, v, L) パラメータ - x + L + + list, tlist, + またはmlistリスト:コンポーネントを変更する必要があるリスト. + + + + + a - 任意の型の行列 + 変更するコンポーネントのアドレス. 文字列として指定されたフィールド名, + または正の整数として指定されたインデックスのいずれかになります. + 詳細については, insertionをご覧ください. + - l + v - list, tlist または mlist 変数 + 任意のScilabオブジェクト:割り当てる値 + - i + uL - フィールド添え字, 詳細は insertion 参照. + 更新されたリスト + @@ -48,18 +63,83 @@ 説明 - この関数は,フィールド展開を行うl(i)=x構文と等価ですが, - 唯一の差異は,mlistオブジェクトにも適用可能なことです. + L=setfield(a,v,L) addresses and changes the + ith element of a list, in a unified way + over lists, tlists and mlists. + + + For simple lists and for tlists, L=setfield(a,v,L) + is equivalent to L(a)=v, that is simpler and should be preferred. + The same stands for any mlist if the address a is a + field's name. + + + However, for any mlist L, if i is an index, the insertion + L(i)=v is not predefined, in order to let the user define + an overload implementing a matrix-oriented insertion, if required. + Yet setfield(i,v,L) is always defined, with the same meaning as + for other list and tlist types. 例 + + For a tlist, setfield(3, v, T) is equivalent to + T(3)=v : + + + 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 +]]> + + For a mlist, there is no predefined indexed insertion routine, to let + the user define a matrix-oriented insertion overload if required. + error + +// But a raw direct insertion with setfield() is always possible: +M = setfield(3, [%t %f %t], M); +getfield(3, M) ]]> + 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 +]]> 参照 @@ -67,6 +147,27 @@ l(6)=['one more';'added'] insertion + + getfield + + + 履歴 + + + 6.0.0 + + + + The updated list is now returned, instead of being changed "in place". + + + setfield() can no longer be used for cells arrays. + + + + + + diff --git a/scilab/modules/data_structures/help/pt_BR/setfield.xml b/scilab/modules/data_structures/help/pt_BR/setfield.xml index e57de6d..40e028b 100644 --- a/scilab/modules/data_structures/help/pt_BR/setfield.xml +++ b/scilab/modules/data_structures/help/pt_BR/setfield.xml @@ -2,8 +2,8 @@ - + setfield - inserção de campos de listas + altera o valor de um elemento de uma mlist, tlist ou list Seqüência de Chamamento - setfield(i,x,l) + uL = setfield(a, v, L) Parâmetros - x + L + + lista do tipo list, tlist ou + mlist : a lista cujo componente deve ser alterado. + + + + + a - matriz de qualquer tipo + 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 inserção + para mais detalhes. + - l + v - lista, tlist ou mlist + Qualquer objeto Scilab : o valor a ser atribuído. + - i + uL - índice de campo, ver "insertion" para mais detalhes. + A lista atualizada. + @@ -48,19 +65,83 @@ Descrição - Esta função é equivalente à sintaxe l(i)=x spara - inserção de campos, com a única diferença de que também se aplica a - objetos mlist. + L=setfield(a,v,L) addresses and changes the + ith element of a list, in a unified way + over lists, tlists and mlists. + + + For simple lists and for tlists, L=setfield(a,v,L) + is equivalent to L(a)=v, that is simpler and should be preferred. + The same stands for any mlist if the address a is a + field's name. + + + However, for any mlist L, if i is an index, the insertion + L(i)=v is not predefined, in order to let the user define + an overload implementing a matrix-oriented insertion, if required. + Yet setfield(i,v,L) is always defined, with the same meaning as + for other list and tlist types. Exemplos + + For a tlist, setfield(3, v, T) is equivalent to + T(3)=v : + + + 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 +]]> + + For a mlist, there is no predefined indexed insertion routine, to let + the user define a matrix-oriented insertion overload if required. + error + +// But a raw direct insertion with setfield() is always possible: +M = setfield(3, [%t %f %t], M); +getfield(3, M) ]]> + 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 +]]> Ver Também @@ -68,6 +149,27 @@ l(6)=['mais um';'adicionado'] insertion + + getfield + + + Histórico + + + 6.0.0 + + + + The updated list is now returned, instead of being changed "in place". + + + setfield() can no longer be used for cells arrays. + + + + + + diff --git a/scilab/modules/data_structures/help/ru_RU/setfield.xml b/scilab/modules/data_structures/help/ru_RU/setfield.xml index 9fed766..70be890 100644 --- a/scilab/modules/data_structures/help/ru_RU/setfield.xml +++ b/scilab/modules/data_structures/help/ru_RU/setfield.xml @@ -2,8 +2,8 @@ - + setfield - внесение поля списка + изменение значения элемента списка типа mlist, tlist или list Синтаксис - setfield(i, x, l) + uL = setfield(a, v, L) Аргументы - x + L - матрица всевозможного типа. + список типа list, tlist или + mlist: список, в котором требуется изменить элемент. + - l + a - - переменная типа list, tlist или mlist. - + адрес элемента, который нужно изменить. Это может быть или его имя + поля, указанного в виде строки, либо его индекс, указанный в виде + положительного целого числа. См. подробности в вставке. + - i + v - - индекс поля, см. справку по вставке. - + любой объект Scilab: значение для присвоения. + + + + + uL + + Обновлённый список. + @@ -52,18 +63,87 @@ Описание - Эта функция является эквивалентом синтаксиса l(i)=x - для вставки поля с той лишь разницей, что она также применима к объектам mlist. + L=setfield(a,v,L) адресует и изменяет + iй элемент списка унифицированным образом + среди списков типа list, tlist и mlist. + + + Для простых списков (list) и для типизированных списков (tlist), + L=setfield(a,v,L) эквивалентно L(a)=v, + то есть проще и должно быть предпочтительнее. Аналогично для любого + матричноориентированного списка (mlist), если адрес a + является именем поля. + + + Тем не менее, для любого матричноориентированного списка + L, если i является индексом, то + вставка L(i)=v не предопределена, для того, чтобы + позволить пользователю определить перегрузку, реализующую + матричноориентированную вставку, если требуется. Вот + setfield(i,v,L) всегда определена, с тем же смыслом, + что и для других списков типа list и tlist. Примеры + + Для списка типа tlist, setfield(3, v, T) эквивалентно + T(3)=v : + + 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 +]]> + + Для списка типа mlist, нет процедуры предопределённой индексированной + вставки, чтобы позволить пользователю определить перегрузку + матричноориентированной вставки, если потребуется. + + error + +// Но необработанная прямая вставка с setfield() всегда возможна: +M = setfield(3, [%t %f %t], M); +getfield(3, M) + ]]> + 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 +]]> Смотрите также @@ -71,7 +151,28 @@ l(6)=['ещё один';'добавлен'] вставка + + getfield + + + История + + + 6.0.0 + + + + Теперь возвращается обновлённый список вместо изменения + "на месте". + + + setfield() больше не может использоваться для cell-массивов. + + + + + + - -- 1.7.9.5