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 (<:m)}.(,|."1)2 comb m }}
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 232
202 212 232 242 252 262 272 282 292 343 353 363
373303 383313 393323 454343 464353 474363 484373 494383 565393
575404 585414 595424 676434 686454 696464 787474 797484 898494
101505 202515 303525 404535 505545 606565 707575 808585 909595
212606 313616 414626 515636 616646 717656 818676 919686 323696
424707 525 626717 727 828737 747 929757 434767 535787 636797
737808 838818 939828 545838 646848 747858 848868 949878 656898
757909 858919 959929 767939 868949 969959 878969 979 989
9 9$und10 4
1010 1212 1313 1414 1515 1616 1717 1818 1919 2323
2020 2121 2323 2424 2525 2626 2727 2828 2929 3434 3535 3636
3030 3131 3232 3434 3535 3636 3737 3838 3939
37374040 38384141 39394242 4343 4545 4646 4747 4848 4949 5656
5757 5858 5959 6767 6868 6969 7878 7979 8989
5050 5151 5252 5353 5454 5656 5757 5858 5959
1010 2020 3030 4040 5050 6060 7070 8080 9090
6060 6161 6262 6363 6464 6565 6767 6868 6969
2121 3131 4141 5151 6161 7171 8181 9191 3232
42427070 5252 62627171 7272 82827373 7474 92927575 43437676 53537878 63637979
8080 8181 8282 8383 8484 8585 8686 8787 8989
7373 8383 9393 5454 6464 7474 8484 9494 6565
75759090 85859191 95959292 76769393 86869494 96969595 87879696 9797 9898
(#~ 1 p:])und10 3
101 131 151 181 191 313 353 373 383 727 757 787 797 101 313 919 727 929 757
(<:600){/:~;und10&.>3+i.>.600%81
4646464646
(#,{:)/:~(#~ (2^53)>:]);und10&.>3+i.>.10^.2^53
1125 8989898989898989
6 7$ und7 3
50 64 71 78 85 92 121 128100
135107 142121 178128 185135 192142 235150 242157
292164 178 50185 100 150192 200 250207 300214
107221 157235 207242 257250 307257 164264 214271
264278 314292 221300 271307 321314 278321 328
335 50 64 71 78 85 92 121
6 7$ und7 4
350 450 500 550 600 650 850 900700
750 850 900 950 1000 1050 1100
950 1000 1250 1300 1350 1650 1700
20501150 1250 3501300 700 10501350 1400 17501450 21001500
1550 1650 1700 1750 1800 1850 1900
750 1100 1450 1800 2150 1150 1500
18501950 22002050 15502100 19002150 22502200 19502250 2300
2350 350 450 500 550 600 650 850
(#~ 1 p:])und7 3
71 107 157 257 307 271 307
fmt7(<:600){/:~;und7&.>3+i.>.600%36
4646464646464646464
(#,&":' ',fmt7@{:)/:~(#~ (2^53)>:]);und7&.>3+i.>.7^.2^53
603 5252525252525252525</syntaxhighlight>
 
6,951

edits