Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"><link rel="stylesheet" href="potigol.css"><head>
<body><button onclick="javascript:window.print();">Print this page</button>
<pre><span class="comentario"></span>x<span class='atribuicao'> = </span>10
<span class="comentario"># Valor fixo
</span><span class='chave'>var </span>y<span class='atribuicao'> := </span>10
<span class="comentario"># Valor alterável
</span>y<span class='atribuicao'> := </span>y <span class='operador'>+</span> 2
</span>5 <span class='operador'>+</span> 3
<span class="comentario"></span>5 <span class='operador'>-</span> 3
<span class="comentario"></span>5 <span class='operador'>*</span> 3
<span class="comentario"></span>5 <span class='operador'>/</span> 3
<span class="comentario"></span>5 <span class='operador'>div</span> 3
<span class="comentario"></span>5 <span class='operador'>mod</span> 3
</span>a<span class='atribuicao'> = </span>leia_inteiro
<span class="comentario"></span>b<span class='atribuicao'> = </span>leia_numero
<span class="comentario"></span>c<span class='atribuicao'> = </span>leia_texto
<span class="comentario"></span>x, y, z<span class='atribuicao'> = </span>leia_inteiro
<span class="comentario"></span>números<span class='atribuicao'> = </span>leia_inteiros<span class='parametros'>(</span>5<span class='parametros'>)</span>
<span class="comentario"># lê um lista de 5 inteiros , um por linha
</span>números<span class='atribuicao'> = </span>leia_inteiros<span class='parametros'>(</span><span class='texto'>","</span><span class='parametros'>)</span>
<span class="comentario"># lê uma lista de números separados por vírgula
</span>Saída
</span><span class='chave'>escreva </span><span class='texto'>"Olá Mundo"</span>
<span class="comentario"># Escreve e passa para a próxima linha
</span><span class='chave'>imprima </span><span class='texto'>"Olá "</span>
<span class="comentario"># Escreve e continua na mesma linha
</span><span class='chave'>escreva </span><span class='texto'>"Mundo"</span>
</span>nome<span class='atribuicao'> = </span><span class='texto'>"Mundo"</span>
<span class="comentario"></span><span class='chave'>escreva </span><span class='texto'>"Olá {</span>nome<span class='texto'>}"</span>
</span><span class='chave'>se </span>x <span class='operador'>&gt;</span> 5<span class='chave'> então </span>
<span class="comentario"></span><span class='chave'>escreva </span><span class='texto'>"Maior do que cinco."</span>
<span class='chave'>fim</span>
</span><span class='chave'>se </span>x <span class='operador'>&gt;</span> 5<span class='chave'> então </span>
<span class="comentario"></span><span class='chave'>escreva </span><span class='texto'>"Maior do que cinco."</span>
<span class='chave'>senão</span>
<span class="comentario"></span><span class='chave'>escreva </span><span class='texto'>"Menor ou igual a cinco."</span>
<span class='chave'>fim</span>
</span><span class='chave'>se </span>x <span class='operador'>&gt;</span> 8<span class='chave'> então </span>
<span class="comentario"></span><span class='chave'>escreva </span><span class='texto'>"Maior do que oito."</span>
<span class='chave'>senãose </span>x <span class='operador'>&gt;</span> 6<span class='chave'> então </span>
<span class="comentario"></span><span class='chave'>escreva </span><span class='texto'>"Maior do que seis."</span>
<span class='chave'>senãose </span>x <span class='operador'>&gt;</span> 4<span class='chave'> então </span>
<span class="comentario"></span><span class='chave'>escreva </span><span class='texto'>"Maior do que quatro."</span>
<span class='chave'>senãose </span>x <span class='operador'>&gt;</span> 2<span class='chave'> então </span>
<span class="comentario"></span><span class='chave'>escreva </span><span class='texto'>"Maior do que dois."</span>
<span class='chave'>senão</span>
<span class="comentario"></span><span class='chave'>escreva </span><span class='texto'>"Menor ou igual a dois."</span>
<span class='chave'>fim</span>
</span><span class='chave'>escolha </span>x
<span class='chave'>caso </span>1<span class='lambda'> => </span><span class="comentario"></span><span class='chave'>escreva </span><span class='texto'>"Um"</span>
<span class='chave'>caso </span>2<span class='lambda'> => </span><span class="comentario"></span><span class='chave'>escreva </span><span class='texto'>"Dois"</span>
<span class='chave'>caso </span>3<span class='lambda'> => </span><span class="comentario"></span><span class='chave'>escreva </span><span class='texto'>"Três"</span>
<span class='chave'>caso </span>_<span class='lambda'> => </span><span class="comentario"></span><span class='chave'>escreva </span><span class='texto'>"Outro valor"</span>
<span class='chave'>fim</span>
</span><span class='chave'>para </span>i<span class='operador'> de </span>1<span class='operador'> até </span>10 <span class='chave'>faça</span>
<span class="comentario"></span><span class='chave'>escreva </span>i
<span class='chave'>fim</span>
</span><span class='chave'>var </span>i<span class='atribuicao'> := </span>0
<span class="comentario"></span><span class='chave'>enquanto </span>i <span class='operador'>&lt;=</span> 10 <span class='chave'>faça</span>
<span class="comentario"></span><span class='chave'>escreva </span>i
<span class="comentario"></span>i<span class='atribuicao'> := </span>i <span class='operador'>+</span> 1
<span class='chave'>fim</span>
</span>soma<span class='parametros'>(</span>x, y<span class='tipo'>: </span><span class='classe'>Inteiro</span><span class='parametros'>)</span><span class='atribuicao'> = </span>x <span class='operador'>+</span> y
</span>a, b<span class='atribuicao'> = </span>leia_inteiro
<span class="comentario"></span>c<span class='atribuicao'> = </span>soma<span class='parametros'>(</span>a, b<span class='parametros'>)</span>
<span class="comentario"></span><span class='chave'>escreva </span><span class='texto'>"{</span>a<span class='texto'>} + {</span>b<span class='texto'>} = {</span>c<span class='texto'>}"</span>
</span>fatorial<span class='parametros'>(</span>n<span class='tipo'>: </span><span class='classe'>Inteiro</span><span class='parametros'>)</span>
<span class="comentario"></span><span class='chave'>var </span>f<span class='atribuicao'> := </span>1
<span class="comentario"></span><span class='chave'>para </span>i<span class='operador'> de </span>2<span class='operador'> até </span>n <span class='chave'>faça</span>
<span class="comentario"></span>f<span class='atribuicao'> := </span>f <span class='operador'>*</span> i
<span class='chave'>fim</span>
<span class="comentario"></span>f
<span class='chave'>fim</span>
</span>a<span class='atribuicao'> = </span>leia_inteiro
<span class="comentario"></span><span class='chave'>escreva </span><span class='texto'>"Fatorial de {</span>a<span class='texto'>} é {</span>fatorial<span class='parametros'>(</span>a<span class='parametros'>)</span><span class='texto'>}"</span>
</span>12345.678<span class='ponto'>.</span>inteiro
<span class="comentario"># 12345
</span>12345.678<span class='ponto'>.</span>arredonde
<span class="comentario"># 12346
</span>12345.678<span class='ponto'>.</span>arredonde<span class='parametros'>(</span>2<span class='parametros'>)</span>
<span class="comentario"># 12345.68
</span>12345.
<span class="comentario"></span>texto
<span class="comentario"># "12345"
</span>12345<span class='operador'> formato </span><span class='texto'>"%8d"</span>
<span class="comentario"># " 12345"
</span>123.45<span class='operador'> formato </span><span class='texto'>"%.1f"</span>
# "123.4"
</span><span class='texto'>"123"</span><span class='ponto'>.</span>inteiro
<span class="comentario"># 123
</span><span class='texto'>"12abc3"</span><span class='ponto'>.</span>inteiro
<span class="comentario"># 12
</span><span class='texto'>"abc"</span><span class='ponto'>.</span>inteiro
<span class="comentario"># 0
</span><span class='texto'>"12.3"</span><span class='ponto'>.</span>real
<span class="comentario"># 12.3
</span><span class='texto'>"12a.3"</span><span class='ponto'>.</span>real
<span class="comentario"># 12.0
</span><span class='texto'>"abc"</span><span class='ponto'>.</span>real
<span class="comentario"># 0.0
</span><span class='texto'>"abc"</span><span class='ponto'>.</span>tamanho
<span class="comentario"># 3
</span><span class='texto'>"abc"</span><span class='ponto'>.</span>posição<span class='parametros'>(</span>'b'<span class='parametros'>)</span>
<span class="comentario"># 2
</span><span class='texto'>"abc"</span><span class='ponto'>.</span>posição<span class='parametros'>(</span>'d'<span class='parametros'>)</span>
<span class="comentario"># 0
</span><span class='texto'>"abc"</span><span class='ponto'>.</span>contém<span class='parametros'>(</span>'a'<span class='parametros'>)</span>
<span class="comentario"># verdadeiro
</span><span class='texto'>"abc"</span><span class='ponto'>.</span>contém<span class='parametros'>(</span>'d'<span class='parametros'>)</span>
<span class="comentario"># falso
</span><span class='texto'>"Abc"</span><span class='ponto'>.</span>maiúsculo
<span class="comentario"># "ABC"
</span><span class='texto'>"Abc"</span><span class='ponto'>.</span>minúsculo
<span class="comentario"># "abc"
</span><span class='texto'>"Abc"</span><span class='ponto'>.</span>inverta
<span class="comentario"># "cbA"
</span><span class='texto'>"Isto é um texto"</span><span class='ponto'>.</span>divida
<span class="comentario"># ["Isto", "é", "um", "texto"]
</span><span class='texto'>"Isto é um texto"</span><span class='ponto'>.</span>divida<span class='parametros'>(</span><span class='texto'>"t"</span><span class='parametros'>)</span>
<span class="comentario"># ["Is", "o é um ", "ex", "o"]
</span><span class='texto'>"Isto é um texto"</span><span class='ponto'>.</span>lista
<span class="comentario"># ["I", "s", "t", "o", " ", "é", " ", "u", "m", " ", "t", "e", "x", "t", "o"]
</span><span class='texto'>"abc"</span><span class='ponto'>.</span>cabeça
<span class="comentario"># 'a'
</span><span class='texto'>"abc"</span><span class='ponto'>.</span>cauda
<span class="comentario"># "bc"
</span><span class='texto'>"abc"</span><span class='ponto'>.</span>último
<span class="comentario"># 'c'
</span><span class='texto'>"abcde"</span><span class='ponto'>.</span>pegue<span class='parametros'>(</span>3<span class='parametros'>)</span>
<span class="comentario"># "abc"
</span><span class='texto'>"abcde"</span><span class='ponto'>.</span>passe<span class='parametros'>(</span>3<span class='parametros'>)</span>
<span class="comentario"># "de"
</span><span class='texto'>"abcb"</span><span class='ponto'>.</span>selecione<span class='parametros'>(</span>letra<span class='lambda'> => </span><span class="comentario"></span>letra <span class='operador'>&lt;&gt;</span> 'c'<span class='parametros'>)</span>
<span class="comentario"># "abb"
</span><span class='texto'>"abcb"</span><span class='ponto'>.</span>passe_enquanto<span class='parametros'>(</span>letra<span class='lambda'> => </span><span class="comentario"></span>letra <span class='operador'>&lt;&gt;</span> 'c'<span class='parametros'>)</span>
<span class="comentario"># "cb"
</span><span class='texto'>"abcb"</span><span class='ponto'>.</span>pegue_enquanto<span class='parametros'>(</span>letra<span class='lambda'> => </span><span class="comentario"></span>letra <span class='operador'>&lt;</span> 'c'<span class='parametros'>)</span>
<span class="comentario"># "ab"
</span><span class='colchete'>[</span>2, 4, 6, 8, 10<span class='colchete'>]</span>
<span class="comentario"># lista literal
</span>2<span class='cons'> :: </span><span class='colchete'>[</span>4, 6, 8, 10<span class='colchete'>]</span>
<span class="comentario"># [2, 4, 6, 8, 10]
</span><span class='colchete'>[</span>2, 4, 6, 8, 10<span class='colchete'>]</span><span class='ponto'>.</span>tamanho
<span class="comentario"># 5
</span><span class='colchete'>[</span>2, 4, 6, 8, 10<span class='colchete'>]</span><span class='ponto'>.</span>cabeça
<span class="comentario"># 2
</span><span class='colchete'>[</span>2, 4, 6, 8, 10<span class='colchete'>]</span><span class='ponto'>.</span>cauda
<span class="comentario"># [4, 6, 8, 10]
</span><span class='colchete'>[</span>2, 4, 6, 8, 10<span class='colchete'>]</span><span class='ponto'>.</span>último
<span class="comentario"># 10
</span><span class='colchete'>[</span>2, 4, 6, 8, 10<span class='colchete'>]</span><span class='ponto'>.</span>pegue<span class='parametros'>(</span>2<span class='parametros'>)</span>
<span class="comentario"># [2, 4]
</span><span class='colchete'>[</span>2, 4, 6, 8, 10<span class='colchete'>]</span><span class='ponto'>.</span>passe<span class='parametros'>(</span>2<span class='parametros'>)</span>
# [6, 8, 10]
</span><span class='colchete'>[</span>2, 4, 6, 8, 10<span class='colchete'>]</span><span class='ponto'>.</span>inverta
<span class="comentario"># [10, 8, 6, 4, 2]
</span><span class='colchete'>[</span>2, 6, 8, 10, 4<span class='colchete'>]</span><span class='ponto'>.</span>ordene
<span class="comentario"># [2, 4, 6, 8, 10]
</span><span class='colchete'>[</span>2, 4, 6<span class='colchete'>]</span> <span class='operador'>+</span> <span class='colchete'>[</span>8, 10<span class='colchete'>]</span>
<span class="comentario"># [2, 4, 6, 8, 10]
</span><span class='colchete'>[</span>2, 4, 6<span class='colchete'>]</span><span class='ponto'>.</span>junte
<span class="comentario"># "246"
</span><span class='colchete'>[</span>2, 4, 6<span class='colchete'>]</span><span class='ponto'>.</span>junte<span class='parametros'>(</span><span class='texto'>", "</span><span class='parametros'>)</span>
<span class="comentario"># "2, 4, 6"
</span><span class='colchete'>[</span>2, 4, 6<span class='colchete'>]</span><span class='ponto'>.</span>junte<span class='parametros'>(</span><span class='texto'>"["</span>, <span class='texto'>", "</span>, <span class='texto'>"]"</span><span class='parametros'>)</span>
<span class="comentario"># "[2, 4, 6]"
</span>a<span class='atribuicao'> = </span><span class='colchete'>[</span>2, 4, 6, 8, 10<span class='colchete'>]</span>
<span class="comentario"></span>a<span class='vetor'>[</span>3<span class='vetor'>]</span>
<span class="comentario"># 6
</span>a<span class='ponto'>.</span>posição<span class='parametros'>(</span>6<span class='parametros'>)</span>
<span class="comentario"># 3
</span>a<span class='ponto'>.</span>posição<span class='parametros'>(</span>12<span class='parametros'>)</span>
<span class="comentario"># 0
</span>a<span class='ponto'>.</span>contém<span class='parametros'>(</span>6<span class='parametros'>)</span>
<span class="comentario"># verdadeiro
</span>a<span class='ponto'>.</span>contém<span class='parametros'>(</span>12<span class='parametros'>)</span>
<span class="comentario"># falso
</span>a<span class='ponto'>.</span>remova<span class='parametros'>(</span>4<span class='parametros'>)</span>
<span class="comentario"># [2, 4, 6, 10]
</span>a<span class='ponto'>.</span>insira<span class='parametros'>(</span>3, 5<span class='parametros'>)</span>
<span class="comentario"># [2, 4, 5, 6, 8, 10]
</span>Lista<span class='ponto'>.</span>imutável<span class='parametros'>(</span>5, 0<span class='parametros'>)</span>
<span class="comentario"># [0, 0, 0, 0, 0]
</span>Lista<span class='ponto'>.</span>vazia<span class='vetor'>[</span>Inteiro<span class='vetor'>]</span>
<span class="comentario"># [] - Lista vazia de inteiros
# Matrizes e Cubos
</span>a<span class='atribuicao'> = </span><span class='colchete'>[</span><span class='colchete'>[</span>1, 2<span class='colchete'>]</span>, <span class='colchete'>[</span>3, 4<span class='colchete'>]</span><span class='colchete'>]</span>
<span class="comentario"># Matriz 2x2
</span>a<span class='vetor'>[</span>2<span class='vetor'>]</span>
<span class="comentario"># [3, 4]
</span>a<span class='vetor'>[</span>2<span class='vetor'>]</span><span class='vetor'>[</span>1<span class='vetor'>]</span>
<span class="comentario"># 3
</span>b<span class='atribuicao'> = </span>Matriz<span class='ponto'>.</span>imutável<span class='parametros'>(</span>2, 2, 0<span class='parametros'>)</span>
<span class="comentario"># b == [[0, 0], [0, 0]]
</span>c<span class='atribuicao'> = </span>Cubo<span class='ponto'>.</span>imutável<span class='parametros'>(</span>2, 2, 2, <span class='texto'>"-"</span><span class='parametros'>)</span>
<span class="comentario"># c == [[["-", "-"],["-", "-"]],[["-", "-"],["-", "-"]]]
</span>c<span class='vetor'>[</span>1<span class='vetor'>]</span><span class='vetor'>[</span>2<span class='vetor'>]</span><span class='vetor'>[</span>1<span class='vetor'>]</span>
<span class="comentario"># "-"
# Listas mutáveis
</span>a<span class='atribuicao'> = </span>Lista<span class='ponto'>.</span>mutável<span class='parametros'>(</span>5, 0<span class='parametros'>)</span>
<span class="comentario"># [0, 0, 0, 0, 0].mutável
</span>a<span class='colchete'>[</span>3<span class='colchete'>]</span><span class='atribuicao'> := </span>5
<span class="comentario"># a == [0, 0, 5, 0, 0].mutável
# Funções de alta-ordem
</span><span class='colchete'>[</span>2, 4, 6, 8, 10<span class='colchete'>]</span><span class='ponto'>.</span>selecione<span class='parametros'>(</span>n<span class='lambda'> => </span><span class="comentario"></span>n <span class='operador'>mod</span> 4 <span class='operador'>==</span> 0<span class='parametros'>)</span>
<span class="comentario"># [4, 8]
</span><span class='colchete'>[</span>2, 4, 6, 8, 10<span class='colchete'>]</span><span class='ponto'>.</span>mapeie<span class='parametros'>(</span>n<span class='lambda'> => </span><span class="comentario"></span>n <span class='operador'>div</span> 2<span class='parametros'>)</span>
<span class="comentario"># [1, 2, 3, 4, 5]
</span><span class='colchete'>[</span>2, 4, 6<span class='colchete'>]</span><span class='ponto'>.</span>injete<span class='parametros'>(</span>0<span class='parametros'>)</span><span class='parametros'>(</span><span class='parametros'>(</span>a, b<span class='parametros'>)</span><span class='lambda'> => </span><span class="comentario"></span>a <span class='operador'>+</span> b<span class='parametros'>)</span>
<span class="comentario"># 0 + 2 + 4 + 6 == 12
</span><span class='colchete'>[</span>2, 4, 6<span class='colchete'>]</span><span class='ponto'>.</span>injete<span class='parametros'>(</span><span class='parametros'>(</span>a, b<span class='parametros'>)</span><span class='lambda'> => </span><span class="comentario"></span>a <span class='operador'>+</span> b<span class='parametros'>)</span>
<span class="comentario"># 2 + 4 + 6 == 12
</span><span class='colchete'>[</span>2, 4, 6, 2, 4<span class='colchete'>]</span><span class='ponto'>.</span>pegue_enquanto<span class='parametros'>(</span>n<span class='lambda'> => </span><span class="comentario"></span>n <span class='operador'>&lt;</span> 6<span class='parametros'>)</span>
<span class="comentario"># [2, 4]
</span><span class='colchete'>[</span>2, 4, 6, 2, 4<span class='colchete'>]</span><span class='ponto'>.</span>passe_enquanto<span class='parametros'>(</span>n<span class='lambda'> => </span><span class="comentario"></span>n <span class='operador'>&lt;</span> 6<span class='parametros'>)</span>
# [6, 2, 4]
</span>t<span class='atribuicao'> = </span>(2015, <span class='texto'>"potigol"</span>, 1.0)
<span class="comentario"># Tupla do tipo (Inteiro, Texto, Real
</span>t<span class='ponto'>.</span>primeiro
<span class="comentario"># 2015
</span>t<span class='ponto'>.</span>segundo
<span class="comentario"># "potigol"
</span>t<span class='ponto'>.</span>terceiro
# 1.0
</span>PI
<span class="comentario"></span>sen<span class='parametros'>(</span>3.14<span class='parametros'>)</span>
<span class="comentario"></span>cos<span class='parametros'>(</span>3.14<span class='parametros'>)</span>
<span class="comentario"></span>tg<span class='parametros'>(</span>1<span class='parametros'>)</span>
<span class="comentario"></span>arcsen<span class='parametros'>(</span>1<span class='parametros'>)</span>
<span class="comentario"></span>arccos<span class='parametros'>(</span>1<span class='parametros'>)</span>
<span class="comentario"></span>arctg<span class='parametros'>(</span>1<span class='parametros'>)</span>
</span>abs<span class='parametros'>(</span>-2.4<span class='parametros'>)</span>
<span class="comentario"># 2.4
</span>raiz<span class='parametros'>(</span>9<span class='parametros'>)</span>
<span class="comentario"># 3.0
</span>log<span class='parametros'>(</span>2<span class='parametros'>)</span>
<span class="comentario"></span>log10<span class='parametros'>(</span>2<span class='parametros'>)</span>
</span>aleatório<span class='parametros'>(</span>null<span class='parametros'>)</span>
<span class="comentario"># número aleatório entre 0 e 1
</span>aleatório<span class='parametros'>(</span>10<span class='parametros'>)</span>
<span class="comentario"># número aleatório entre 1 e 10
</span>aleatório<span class='parametros'>(</span>1, 6<span class='parametros'>)</span>
<span class="comentario"># número aleatório entre 1 e 6
</span>aleatório<span class='parametros'>(</span><span class='colchete'>[</span>2, 4, 6, 8, 10<span class='colchete'>]</span><span class='parametros'>)</span>
# número aleatório pertencente à lista [2, 4, 6, 8, 10]
# QuickSort
</span>quicksort<span class='parametros'>(</span>num<span class='tipo'>: </span><span class='classe'>Lista</span><span class='generico'>[</span><span class='classe'>Inteiro</span><span class='generico'>]</span><span class='parametros'>)</span><span class='tipo'>: </span><span class='classe'>Lista</span><span class='generico'>[</span><span class='classe'>Inteiro</span><span class='generico'>]</span><span class='atribuicao'> = </span><span class='chave'>escolha </span>num
<span class='chave'>caso </span><span class='colchete'>[</span><span class='colchete'>]</span><span class='lambda'> => </span><span class="comentario"></span><span class='colchete'>[</span><span class='colchete'>]</span>
<span class='chave'>caso </span>pivo<span class='cons'> :: </span>resto<span class='lambda'> => </span><span class="comentario"></span>menores<span class='atribuicao'> = </span>resto<span class='ponto'>.</span>filtre<span class='parametros'>(</span>_ <span class='operador'>&lt;=</span> pivo<span class='parametros'>)</span>
<span class="comentario"></span>maiores<span class='atribuicao'> = </span>resto<span class='ponto'>.</span>filtre<span class='parametros'>(</span>_ <span class='operador'>&gt;</span> pivo<span class='parametros'>)</span>
<span class="comentario"></span>quicksort<span class='parametros'>(</span>menores<span class='parametros'>)</span> <span class='operador'>+</span> pivo<span class='cons'> :: </span>quicksort<span class='parametros'>(</span>maiores<span class='parametros'>)</span>
<span class='chave'>fim</span>
</span><span class='chave'>escreva </span><span class='texto'>"Digite alguns números separados por espaços"</span>
<span class="comentario"></span>numeros<span class='atribuicao'> = </span>leia_inteiros<span class='parametros'>(</span><span class='texto'>" "</span><span class='parametros'>)</span>
<span class="comentario"></span><span class='chave'>escreva </span><span class='texto'>"Os números ordenados:"</span>
<span class="comentario"></span><span class='chave'>escreva </span>quicksort<span class='parametros'>(</span>numeros<span class='parametros'>)</span>
</span>numeros<span class='atribuicao'> = </span><span class='colchete'>[</span>1, 2, 3, 4, 5, 6, 7, 8<span class='colchete'>]</span>
<span class="comentario"></span>pares<span class='atribuicao'> = </span>numeros<span class='ponto'>.</span>filtre<span class='parametros'>(</span>n<span class='lambda'> => </span><span class="comentario"></span>n <span class='operador'>mod</span> 2 <span class='operador'>==</span> 0<span class='parametros'>)</span>
<span class="comentario"></span>soma<span class='atribuicao'> = </span>numeros<span class='ponto'>.</span>injete<span class='parametros'>(</span>0<span class='parametros'>)</span><span class='parametros'>(</span><span class='parametros'>(</span>a, b<span class='parametros'>)</span><span class='lambda'> => </span><span class="comentario"></span>a <span class='operador'>+</span> b<span class='parametros'>)</span>
<span class="comentario"></span>dobro<span class='atribuicao'> = </span>numeros<span class='ponto'>.</span>mapeie<span class='parametros'>(</span>n<span class='lambda'> => </span><span class="comentario"></span>n <span class='operador'>*</span> 2<span class='parametros'>)</span>
</pre>
</body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment