This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
[DESAFIO / LANGUAGE WAR] Implemente um programa na sua linguagem favorita onde o usuário digita um número x, e o programa calcula o somatório dos x primeiros números pares da sequência fibonacci, e imprime a soma dos algarismos desse número. | |
Por exemplo, quando x = 5, a resposta é 17, pois: | |
1. A sequência fibonacci é 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233,... | |
2. Os 5 primeiros números pares são 0, 2, 8 e 34, 144. | |
3. O somatório disso é 188. | |
4. Somando os algarismos, 1+8+8 = 17 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl6 | |
use v6; | |
sub MAIN ($x) { | |
([+] ([+] ((^2, * + * ... *).grep(* %% 2))[^$x]).comb).say; | |
} | |
# [DESAFIO / LANGUAGE WAR] | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Fib using: Platform where | |
open Platform Prelude expose [+, parse, as-string, ~] | |
open Platform List expose [zip:using:, map:, take:, filter:, sum] | |
open Platform IO expose [read-line, print] | |
-- Typing things is currently cumbersome, but the type inference algorithm should catch 90% of this | |
let (Num a) => String -> a :: | |
x as-number = x parse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl6 | |
use v6; | |
# caça-palavras em P6 | |
"Só um outro jogo de caça-palavras...".say; | |
"Diga o número de === colunas ~ linhas ===.".say; | |
my $limite = prompt "Qual o limite que você quer?" ~ " "; | |
my @numeros = ^$limite; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/home/usuario/localperl/bin/perl | |
# multidispatch functions | |
use v5.20; | |
use feature qw/ say signatures /; | |
use strict; | |
use warnings; | |
#------------------------------------------------# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.text | |
.macro dec reg, cond | |
sub\cond \reg, \reg, #1 | |
.endm | |
.macro push reg, cond | |
str\cond \reg, [sp], #-4 | |
.endm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/home/user/localperl/bin/perl | |
use v5.20; | |
use strict; | |
use warnings; | |
# linked lists test | |
use feature qw| say signatures |; | |
use Data::Dumper; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\ == recursive version == | |
: fib | |
dup 2 <= if | |
drop 1 | |
else | |
dup 1 - recurse | |
swap 2 - recurse + | |
then ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.text | |
.global _start | |
_start: | |
@ call the fib(10) | |
mov r0, #10 | |
bl _fib | |
@ clear registers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/home/user/localperl/bin/perl | |
use v5.20; | |
use strict; | |
use warnings; | |
use feature qw| say signatures |; | |
my %multi; | |
sub def ($name, $param, $lambda) { |