Revision 45aaba97-c5a5-405d-a2d2-c9c1812ed5fc - Code Golf Stack Exchange

# [APL (Dyalog Unicode)], <s>38</s> 36 bytes

Thanks to ngn for fixing a bug while maintaining byte count.

<!-- language-all: lang-apl -->

Anonymous tacit prefix function. Requires `⎕IO` (**I**ndex **O**rigin) set to `0`, which is default on many systems. Even works for 0!

 ⍕,{2↑'thstndrd'↓⍨2×⊃⍵⌽∊1 0 8\⊂10↑⍳4}

[Try it online!][TIO-jgqvii2e]

[APL (Dyalog Unicode)]: https://www.dyalog.com/
[TIO-jgqvii2e]: https://tio.run/##SyzI0U2pTMzJT///qG9qZv6jtgkG/9OA5KPeqTrVRo/aJqqXZBSX5KUUpag/apv8qHeF0eHpj7qaH/VufdSz91FHl6GCgYJFzKOuJkMDoOJHvZtNav//T1Mw4EpTMARiIwUFIGkMJk2ApLqenp46SM4QLGQIkTc0RpIyMgCLGYG1G4EIYxBhAgA "APL (Dyalog Unicode) – Try It Online"

`{`…`}` anonymous lambda; `⍵` is argument:

 `⍳4` first four **ɩ**ndices; `[0,1,2,3]`

 `10↑` take first ten elements from that, padding with zeros: `[0,1,2,3,0,0,0,0,0,0]`

 `⊂` enclose to treat as single element; `[[0,1,2,3,0,0,0,0,0,0]]`

 `1 0 8\` expand to one copy, a prototypical copy (all-zero), eight copies; 
  <code>[[0,1,2,3,0,0,0,0,0,0],</code> 
  <code> [0,0,0,0,0,0,0,0,0,0],</code> 
  <code> [0,1,2,3,0,0,0,0,0,0],</code> 
  <code> [0,1,2,3,0,0,0,0,0,0],</code> 
   ⋮ (5 more) 
  <code> [0,1,2,3,0,0,0,0,0,0]]</code> 

 `∊` **ϵ**nlist (flatten); 
  <code>[0,1,2,3,0,0,0,0,0,0,</code> 
  <code> 0,0,0,0,0,0,0,0,0,0,</code> 
  <code> 0,1,2,3,0,0,0,0,0,0,</code> 
  <code> 0,1,2,3,0,0,0,0,0,0,</code> 
   ⋮ (50 more) 
  <code> 0,1,2,3,0,0,0,0,0,0]</code>

 `⍵⌽` cyclically rotate left as many steps as indicated by the argument

 `⊃` pick the first number (i.e. the argument-mod-100'th number)

 `2×` multiply two by that (gives `0`, `2`, `4`, or `6`)

 `'thstndrd'↓⍨`drop that many characters from this string

 `2↑` take the first two of the remaining characters

`⍕,` concatenate the stringified argument to that

AltStyle によって変換されたページ (->オリジナル) /