Boustrophedon transform: Difference between revisions

m
→‎{{header|Raku}}: change ordering to match task description
m (Doh. Thinko)
m (→‎{{header|Raku}}: change ordering to match task description)
Line 49:
<syntaxhighlight lang="raku" line>sub boustrophedon-transform (@seq) { map *.tail, ([@seq[0]], {[[\+] flat @seq[++$ ], .reverse]}…*) }
 
sub abbr ($_) { .chars < 41 ?? $_ !! .substr(0,20) ~ '..' ~ .substr(*-20) ~ " ({.chars} digits)" }
 
for '1 followed by 0\'s A000111', (flat 1, 0 xx *),
'All-1\'s A000667', (flat 1 xx *),
'-(-1)^n A062162', (flat 1, [\×] -1 xx *),
'Primes A000747', (^∞ .grep: &is-prime),
'FactorialsFibbonaccis A230960A000744', (1,|[\×] 1..∞,*+*…*),
'FibbonaccisFactorials A000744 A230960', (1,|[\×] 1,*+*…*..∞)
-> $name, $seq
{ say "\n$name:\n" ~ (my $b-seq = boustrophedon-transform $seq)[^15] ~ "\n1000th term: " ~ abbr $b-seq[999] }</syntaxhighlight>
Line 68:
1000th term: 29375506567920455903…86575529609495110509 (2370 digits)
 
-1 × (-1)^n A062162:
1 0 0 1 0 5 10 61 280 1665 10470 73621 561660 4650425 41441530
1000th term: 12694307397830194676…15354198638855512941 (2369 digits)
Line 75:
2 5 13 35 103 345 1325 5911 30067 172237 1096319 7677155 58648421 485377457 4326008691
1000th term: 13250869953362054385…82450325540640498987 (2371 digits)
 
Factorials A230960:
1 2 5 17 73 381 2347 16701 134993 1222873 12279251 135425553 1627809401 21183890469 296773827547
1000th term: 13714256926920345740…19230014799151339821 (2566 digits)
 
Fibbonaccis A000744:
1 2 5 14 42 144 563 2526 12877 73778 469616 3288428 25121097 207902202 1852961189
1000th term: 56757474139659741321…66135597559209657242 (2370 digits)</pre>
 
Factorials A230960:
1 2 5 17 73 381 2347 16701 134993 1222873 12279251 135425553 1627809401 21183890469 296773827547
1000th term: 13714256926920345740…19230014799151339821 (2566 digits)</pre>
10,327

edits