1 <?xml version="1.0" encoding="UTF-8"?>
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) - INRIA
5 * Copyright (C) 2018 - Samuel GOUGEON
7 * Copyright (C) 2012 - 2016 - Scilab Enterprises
9 * This file is hereby licensed under the terms of the GNU GPL v2.0,
10 * pursuant to article 5.3.4 of the CeCILL v.2.1.
11 * This file was originally licensed under the terms of the CeCILL v2.1,
12 * and continues to be available under such terms.
13 * For more information, see the COPYING file which you should have received
14 * along with this program.
17 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
18 xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml"
19 xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook"
20 xmlns:scilab="http://www.scilab.org" xml:id="for" xml:lang="pt">
22 <refname>for</refname>
23 <refpurpose>palavra-chave de linguagem para laços ("loops") (significa
28 <title>Descrição</title>
30 Usado para definir laços ("loops"). sua sintaxe é: <literal> for
31 variável=expressão ,instrução, ... ,instrução,end
35 <literal> for variável= expressão do instrução, ...
40 Se <literal>expressão</literal> é uma matriz ou um vetor linha,
41 <literal>variável</literal> toma como valores os valores de cada coluna da
45 Um caso particular utiliza o operador <link linkend="colon">colon</link> para criar vetores linhas regularmente
46 espaçados, e remonta a formas de laço "for" tradicionais : <literal>for
47 variable=n1:step:n2, ...,end
51 Se <literal>expressão </literal>é uma lista,
52 <literal>variável</literal> toma como valores as entradas sucessivas da
55 <para>Aviso: o número de caracteres usados para definir o corpo de
56 qualquer instrução condicional (if, while, for ou select/case) deve ser
61 <title>Exemplos</title>
62 <para>Lacetes iterativos comum :</para>
63 <programlisting role="example"><![CDATA[
64 // laços "for" tradicionais
65 >>>>>>> 58f750d5cbc... * Bug 12198 (+NRT): 'break case..while' & clear no longer overloadable as in end=1
77 <para>Laço "decrescente" :</para>
78 <programlisting role="example"><![CDATA[
83 <para>Laço implícito sobre as colunas de uma linha ou de uma matriz :</para>
84 <programlisting role="example"><![CDATA[
85 M = [1 2 ; 3 4 ; 5 6]'
89 -> M = [1 2 ; 3 4 ; 5 6]'
105 end // laço decrescente
107 //laço em colunas de matrizes
108 for e=eye(3,3), e, end
109 for v=a, write(6,v), end
110 for j=1:n, v=a(:,j), write(6,v), end
112 //laço em listas de entradas
113 for l=list(1,2,'example'); l, end
114 >>>>>>> 58f750d5cbc... * Bug 12198 (+NRT): 'break case..while' & clear no longer overloadable as in end=1
120 <programlisting role="example"><![CDATA[
121 for v = a, write(%io(2),v), end
122 for j = 1:n, v = a(:,j), write(%io(2),v), end
124 <para>Laço em listas de entradas :</para>
125 <programlisting role="example"><![CDATA[
126 for l = list([1 2;3 4], (1+%z)^3, 'example', [%F %T]); l, end
129 --> for l = list([1 2;3 4], (1+%z)^3, 'example', [%F %T]); l, end
145 <refsection role="see also">
146 <title>Ver Também</title>
147 <simplelist type="inline">
149 <link linkend="while">while</link>
152 <link linkend="end">end</link>
155 <link linkend="do">do</link>
159 <refsection role="history">
160 <title>Histórico</title>
163 <revnumber>6.0.0</revnumber>
165 The for <literal>expression</literal> can now be a vector of graphic handles.
166 <literal>for</literal> is now protected:
167 Assignments like <literal>for=1</literal> are no longer possible.