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
76 <para>Laço "decrescente" :</para>
77 <programlisting role="example"><![CDATA[
82 <para>Laço implícito sobre as colunas de uma linha ou de uma matriz :</para>
83 <programlisting role="example"><![CDATA[
84 M = [1 2 ; 3 4 ; 5 6]'
88 -> M = [1 2 ; 3 4 ; 5 6]'
106 <programlisting role="example"><![CDATA[
107 for v = a, write(%io(2),v), end
108 for j = 1:n, v = a(:,j), write(%io(2),v), end
110 <para>Laço em listas de entradas :</para>
111 <programlisting role="example"><![CDATA[
112 for l = list([1 2;3 4], (1+%z)^3, 'example', [%F %T]); l, end
115 --> for l = list([1 2;3 4], (1+%z)^3, 'example', [%F %T]); l, end
131 <refsection role="see also">
132 <title>Ver Também</title>
133 <simplelist type="inline">
135 <link linkend="while">while</link>
138 <link linkend="end">end</link>
141 <link linkend="do">do</link>
145 <refsection role="history">
146 <title>Histórico</title>
149 <revnumber>6.0.0</revnumber>
151 The for <literal>expression</literal> can now be a vector of graphic handles.
152 <literal>for</literal> is now protected:
153 Assignments like <literal>for=1</literal> are no longer possible.