Subleq: Difference between revisions
Content deleted Content added
Subleq en FreeBASIC |
|||
Line 2,716: | Line 2,716: | ||
(formerly Perl 6) |
(formerly Perl 6) |
||
{{trans|Perl}} |
{{trans|Perl}} |
||
<lang perl6>my @hello-world = |
<lang perl6>my @hello-world = |
||
|<15 17 -1 17 -1 -1 16 1 -1 16 3 -1 15 15 0 0 -1>, |
|||
|"Hello, world!\n\0".comb.map(*.ord); |
|||
sub run-subleq(@memory) { |
|||
my $ip = 0; |
my $ip = 0; |
||
while $ip >= 0 && $ip < @memory { |
while $ip >= 0 && $ip < @memory { |
||
my ($a, $b, $c) = @memory[$ip |
my ($a, $b, $c) = @memory[$ip..*]; |
||
$ip += 3; |
$ip += 3; |
||
if $a < 0 { |
if $a < 0 { |
||
@memory[$b] = getc.ord; |
|||
} elsif $b < 0 { |
} elsif $b < 0 { |
||
print @memory[$a].chr; |
|||
} else { |
} else { |
||
if (@memory[$b] -= @memory[$a]) <= 0 { |
|||
$ip = $c; |
|||
} |
|||
} |
} |
||
} |
|||
}</lang> |
|||
} |
|||
run-subleq @hello-world;</lang> |
|||
{{out}} |
{{out}} |