Undulating numbers: Difference between revisions
m
→{{header|J}}: presort undul numbers - this could be made more efficient by sorting when the base is chosen
(J draft (hopefully these expressions are sufficient labels for their results)) |
m (→{{header|J}}: presort undul numbers - this could be made more efficient by sorting when the base is chosen) |
||
Line 233:
So, given:
<syntaxhighlight lang=J>require'stats'
undul=: {{ /:~ m #. y$"1
und10=: 10 undul
und7=: 7 undul
fmt7=: 7{{' '-.~":m&#.inv y}}</syntaxhighlight>
We get:
<syntaxhighlight lang=J> 9 9$und10 3
101 121 131 141 151 161 171 181 191
202 212 232 242 252 262 272 282 292
9 9$und10 4
1010 1212 1313 1414 1515 1616 1717 1818 1919
2020 2121 2323 2424 2525 2626 2727 2828 2929
3030 3131 3232 3434 3535 3636 3737 3838 3939
5050 5151 5252 5353 5454 5656 5757 5858 5959
6060 6161 6262 6363 6464 6565 6767 6868 6969
8080 8181 8282 8383 8484 8585 8686 8787 8989
(#~ 1 p:])und10 3
101 131 151 181 191 313 353 373 383 727 757 787 797
(<:600){
4646464646
(#,{:)
1125 8989898989898989
6 7$ und7 3
50 64 71 78 85 92
335 50 64 71 78 85 92
6 7$ und7 4
350 450 500 550 600 650
750 850 900 950 1000 1050 1100
1550 1650 1700 1750 1800 1850 1900
2350 350 450 500 550 600 650
(#~ 1 p:])und7 3
71 107 157 257
fmt7(<:600){
4646464646464646464
(#,&":' ',fmt7@{:)
603 5252525252525252525</syntaxhighlight>
|