Partly inspired by Leaky Nun's solution.
Normal:
⁵Ŀ⁵
R
R²
2*R
‘
⁵Ŀ⁵
Try it online!
Input: 5
Output:
610
Reversed:
⁵Ŀ⁵
‘
R*2
²R
R
⁵Ŀ⁵
Try it online!
Input: 5
Output:
[1, 2, 3, 4, 5]10
Doubled
⁵Ŀ⁵
R
R²
2*R
‘
⁵Ŀ⁵
⁵Ŀ⁵
R
R²
2*R
‘
⁵Ŀ⁵
Try it online!
Input: 5
Output:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]10
Doubled and Reversed
⁵Ŀ⁵
‘
R*2
²R
R
⁵Ŀ⁵
⁵Ŀ⁵
‘
R*2
²R
R
⁵Ŀ⁵
Try it online!
Input: 5
Output:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]10
Explanation
The key here is in Ŀ
, which means "calls the link at index n as a monad." The links are indexed top to bottom starting at 1, excluding the main link (the bottom-most one). Ŀ
is modular as well, so if you try to call link number 7 out of 5 links, you'll actually call link 2.
The link being called in this program is always the one at index 10 (⁵
) no matter what version of the program it is. However, which link is at index 10 depends on the version.
The ⁵
that appears after each Ŀ
is there so it doesn't break when reversed. The program will error out at parse-time if there is no number before Ŀ
. Having a ⁵
after it is an out of place nilad, which just goes straight to the output.
The original version calls the link ‘
, which computes n+1.
The reversed version calls the link R
, which generates the range 1 .. n.
The doubled version calls the link 2*R
, which computes 2n and generates the range 1 .. 2n.
The doubled and reversed version calls the link ²R
, which computes n2 and generates the range 1 .. n2.