Boustrophedon transform: Difference between revisions

J draft
(J draft)
Line 46:
 
 
=={{header|J}}==
Implementation:<syntaxhighlight lang=J>b=: {{
M=: (u i.y),.(y-0 1)$x:_
B=:{{
if. x<y do.0
else. i=. <x,y
if. _>i{M do. i{M
else. r=. (x B y-1)+(x-1) B x-y
r[M=: r i} M
end.
end.
}}"0
(<0 1)|:B/~i.y
}}</syntaxhighlight>
Task examples:<syntaxhighlight lang=J> =&0 b 15
1 1 1 2 5 16 61 272 1385 7936 50521 353792 2702765 22368256 199360981
1"0 b 15
1 2 4 9 24 77 294 1309 6664 38177 243034 1701909 13001604 107601977 959021574
_1x&^ b 15
1 0 0 1 0 5 10 61 280 1665 10470 73621 561660 4650425 41441530
p: b 15
2 5 13 35 103 345 1325 5911 30067 172237 1096319 7677155 58648421 485377457 4326008691
phi=: -:>:%:5
{{ <.0.5+(phi^y)%%:5 }} b 15
0 1 3 8 25 85 334 1497 7635 43738 278415 1949531 14893000 123254221 1098523231
!@x: b 15
1 2 5 17 73 381 2347 16701 134993 1222873 12279251 135425553 1627809401 21183890469 296773827547</lang>
=={{header|Julia}}==
<syntaxhighlight lang="julia">using Primes
6,962

edits