[Question]
  [
I [didn't](https://github.zhaw.ch/munt/Gulf) invent this challenge, but I find it very interesting to solve.
For **every** input number, e.g.:
```
4
```
Generate a range from 1 to that number:
```
[1 2 3 4]
```
And then, for every item in that list, generate a list from 1 to that number:
```
[[1] [1 2] [1 2 3] [1 2 3 4]]
```
Then, reverse every item of that list.
```
[[1] [2 1] [3 2 1] [4 3 2 1]]
```
## Notes:
* 1 being a loose item is allowed, since flattening will not matter with this anyway.
* To preserve the spirit of the challenge, the range has to be 1-indexed.
* You may flatten the list if your platform doesn't support the concept of nested lists.
  
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), ~~5~~ 4 [bytes](https://codegolf.meta.stackexchange.com/a/9429/43319 "When can APL characters be counted as 1 byte each?")[SBCS](https://github.com/abrudz/SBCS ".dyalog files using a single byte character set")
Anonymous tacit prefix function.
```
,⍨\⍳
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///X@dR74qYR72b/6c9apvwqLfvUd9UT/9HXc2H1hs/apsI5AUHOQPJEA/P4P9A2ivY308hTcEEAA "APL (Dyalog Unicode) – Try It Online")
`,⍨\` cumulative reverse-concatenation reduction of
`⍳` the iota
[Answer]
# [R](https://www.r-project.org/), ~~22~~ 19 bytes
```
Map(`:`,1:scan(),1)
```
[Try it online!](https://tio.run/##K/r/3zexQCPBKkHH0Ko4OTFPQ1PHUPO/6X8A "R – Try It Online")
`Map(f,...)` applies `f` elementwise to each member of `...`, recycling as needed, resulting in a `list`, so we just supply `1` as the `to` argument to `:` to get the reversed.
-3 bytes thanks to [Vlo](https://codegolf.stackexchange.com/users/30693/vlo)!
[Answer]
# Jelly, 3 bytes
```
RRU
```
```
R     Range from 1 to input
 R    (implicitly) map over said range and create a range from 1 to this element
  U   reverse each of those
```
You can [try it online!](https://tio.run/##y0rNyan8/z8oKPT///8mAA)
Courtesy of @JonathanAllan, we also have two other 3-"byters"
```
RrL
RrE
```
I think it is not often that golfing languages solve a challenge with only `a-zA-Z` characters
[Answer]
# Pure [Bash](https://www.gnu.org/software/bash/) (no external utilities), 29
```
eval eval echo \\{{1..$1}..1}
```
[Try it online!](https://tio.run/##S0oszvj/P7UsMUcBQiRn5CvExFRXG@rpqRjW6ukZ1v7//98EAA "Bash – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 3 bytes
```
LLí
```
[Try it online!](https://tio.run/##yy9OTMpM/f/fx@fw2v//TQA "05AB1E – Try It Online")
[Answer]
# [shell + sed](https://www.gnu.org/software/bash/), 15 bytes
```
seq $1|sed G\;h
```
[Try it online!](https://tio.run/##S0oszvj/vzi1UEHFsKY4NUXBPcYaKPDfBAA "Bash – Try It Online")
Outputs like so, `1\n\n2\n1\n\n3\n2\n1\n\n[...]`
`seq $1` creates a sequence from 1 to the first argument `$1`
`|sed ...` which is piped into a sed script
sed works on a line-by-line basis; it first reads the first line into the buffer, called the "pattern space", after which the program commands is run on it. At the end of the program's execution on the first line, the remaining pattern space is implicitly printed. Then sed reads the next line into the pattern space, replacing the previous contents, and runs the commands on it, repeating for all lines of input (unless a command specifies otherwise).
The pattern space is not saved between lines, but what is is the hold space. The hold space is another buffer, that starts empty, and can be modified by program commands. Its contents are carried on to the execution of the next line of input.
The `G` command appends a newline followed by the content of the hold space to that of the pattern space. Then the `h` command replaces the hold space with the content of the pattern space. This effectively reverses the lines of input encountered so far, writing them to the pattern space – implicitly printing at the end of processing the current line – and saving them to the hold space so that upon reading subsequent lines of input, the new reversed "list" can be constructed with `G;h`.
The `;` is escaped in the program as `\;` because otherwise the shell interprets it as terminating a shell command.
[Answer]
# [~~Perl 6~~ Raku](https://github.com/nxadm/rakudo-pkg), ~~24 15 13~~ 10 bytes
-2 removed parenthesis
-3 thanks to nwellnhof
```
^*+1 X…1
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYPs/TkvbUCHiUcMyw//WXMWJlQppCib/AQ)
## Explanation
```
^*+1     # make a range from 1 .. argument (whatever star).
     X…1 # create ranges descending to 1 using cross product metaoperator.
```
## Previous version, 24 bytes
```
(^<<(^*+1)X+1)>>.reverse
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYPtfI87GRiNOS9tQMwKI7ez0ilLLUouKU/9bc3EVJ1YqpCmY/AcA "Perl 6 – Try It Online")
### Explanation
```
     ^*+1                # make a range from 1 .. argument (whatever star)
 ^<<(    )               # replace each element with a range from 0 .. element - 1
                         # (via hyper prefix operator)
          X+1            # shift the range to 1 .. element
                         # (via cross product metaoperator)
(            )>>.reverse # reverse each list (via hyper method operator)
```
[Answer]
# [K (ngn/k)](https://bitbucket.org/ngn/k), 8 bytes
```
|',\1+!:
```
[Try it online!](https://tio.run/##y9bNS8/7/z/NqkZdJ8ZQW9Hqf5qCyX8A "K (ngn/k) – Try It Online")
-2 thanks to ngn :-)
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 20 bytes
```
Range[Range@#,1,-1]&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n277PygxLz01Gkw6KOsY6ugaxqr9DyjKzCtRcEiPNon9/x8A "Wolfram Language (Mathematica) – Try It Online")
-3 bytes from @att
[Answer]
# JavaScript (ES6), ~~50~~ 49 bytes
*Saved 1 byte thanks to @Shaggy*
```
f=n=>n?[...f(n-1),(g=_=>n?[n,...g(--n)]:[])()]:[]
```
[Try it online!](https://tio.run/##HchRCoAgDADQ62zQBkFfgXUQkRBTKWRGRtdf4deDd/rXt3Af10NS96iajJhFVsvMCYRGHCCbrZcMf2YgEnSzdQgdDVVaLZFLzZBgQtQP "JavaScript (Node.js) – Try It Online")
[Answer]
# [PHP](https://php.net/), 54 bytes
```
function($x){for(;$y<$x;$a[]=range(++$y,1));return$a;}
```
[Try it online!](https://tio.run/##Fc0xCsIwFAbgPafI8A8JtYPg9hrcvEQpEmLS6PBeSFtoEa9uxO8CX8mlDdeSi0JyLW0c1qewwW7fSaohHAN2gh8nVz3P0XQdjtPZWqpx3SrD06eRgminkYyGrzNrSyqGLPq1CN8jB3lEA7HULl8p/2Bp/e0H "PHP – Try It Online")
Or recursive:
# [PHP](https://php.net/), 54 bytes
```
function f($x){return$x?f($x-1)+[$x=>range($x,1)]:[];}
```
[Try it online!](https://tio.run/##K8go@G9jXwAk00rzkksy8/MU0jRUKjSri1JLSovyVCrsQVxdQ03taJUKW7uixLz0VKCAjqFmrFV0rHXt/9TkjHyFrOL8vPjUvOT8lFQNoH4FlcSi9DwFTQVN6/8m//ILQMYW/9d1AwA "PHP – Try It Online")
Or with PHP-formatted printed output:
# [PHP](https://php.net/), 38 bytes
```
for(;$x<$argn;print_r(range(++$x,1)));
```
[Try it online!](https://tio.run/##K8go@G9jXwAk0/KLNKxVKmxUEovS86wLijLzSuKLNIoS89JTNbS1VSp0DDU1Na3//zf5l19QkpmfV/xf1w0A "PHP – Try It Online")
[Answer]
# [Raku](https://github.com/nxadm/rakudo-pkg), 13 bytes
```
{[\R,] 1..$_}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYKvwvzo6JkgnVsFQT08lvvZ/cWKlQpqCyX8A "Perl 6 – Try It Online")
Cumulative reverse with the range 1 to input.
[Answer]
# x86-16 machine code, 12 bytes
Binary:
```
00000000: 33c0 4050 ab48 75fc 58e2 f7c3         [[email protected]](/cdn-cgi/l/email-protection)...
```
Unassembled listing:
```
33 C0       XOR  AX, AX         ; AX = 0
        OUT_LOOP:
40          INC  AX             ; start at 1
50          PUSH AX             ; save starting position
        IN_LOOP:
AB          STOSW               ; write to output buffer, increment DI
48          DEC  AX             ; AX--
75 FC       JNZ  IN_LOOP        ; if AX > 0, keep looping
58          POP  AX             ; restore starting position
E2 F7       LOOP OUT_LOOP 
C3          RET                 ; return to caller
```
Input Number in `CX`, output array of `WORD`, at `[DI]`.
Example I/O using DOS test driver program:
[![enter image description here](https://i.stack.imgur.com/qdFUf.png)](https://i.stack.imgur.com/qdFUf.png)
[Answer]
# [BQN](https://mlochbaum.github.io/BQN/), 10 bytes
Anonymous tacit prefix function.
```
(⌽1+↕)¨1+↕
```
[Try it online!](https://bqnpad.mechanize.systems/s?bqn=eyJkb2MiOiJcblxuIyBGb3IgZXZlcnkgaW5wdXQgbnVtYmVyLCBnZW5lcmF0ZSBhIHJhbmdlIGZyb20gMSB0byB0aGF0IG51bWJlci5cbiMgRm9yIGV2ZXJ5IGl0ZW0gaW4gdGhhdCBsaXN0LCBnZW5lcmF0ZSBhIGxpc3QgZnJvbSAxIHRvIHRoYXQgbnVtYmVyLlxuIyBSZXZlcnNlIGV2ZXJ5IGl0ZW0gb2YgdGhhdCBsaXN0LlxubiDihpAgNVxuU29sMCDihpAgKOKMvTEr4oaVKcKoMSvihpVcblNvbDEg4oaQICgxK%2BKGlSl7KOKMvfCdlL0pwqjwnZS9fVxuU29sMiDihpAgKOKMveKGlSnCqOKGlVxuXG5Tb2wwIG5cblxuIiwicHJldlNlc3Npb25zIjpbXSwiY3VycmVudFNlc3Npb24iOnsiY2VsbHMiOltdLCJjcmVhdGVkQXQiOjE2NzUwMDU4NzEzMzV9LCJjdXJyZW50Q2VsbCI6eyJmcm9tIjowLCJ0byI6MjQzLCJyZXN1bHQiOm51bGx9fQ%3D%3D)
### Explanation
```
(⌽1+↕)¨1+↕
       1+↕    1.  Get list of integers from 1 to n.
      ¨       2a. For each integer i in the list...
( 1+↕)        2b. get a list of integers from 1 to i...
(⌽   )        2c. and then reverse that list.
```
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 19 bytes
```
1.."$args"|%{$_..1}
```
[Try it online!](https://tio.run/##K8gvTy0qzkjNyfn/31BPT0klsSi9WKlGtVolXk/PsPb///8mAA "PowerShell – Try It Online")
Generates the range from `1` to input `$args`, then constructs the reversed range for each of those numbers. Tack on a [`-join`](https://tio.run/##K8gvTy0qzkjNyfn/31BPT0klsSi9WKlGtVolXk/PUDcrPzNPXUe99v///yYA "PowerShell – Try It Online") to better see how the arrays are created (because PowerShell inserts a newline between each element, it's tough to see the individual arrays).
[Answer]
# [Python 3](https://docs.python.org/3/), 46 bytes
```
lambda n:[[*range(i+1,0,-1)]for i in range(n)]
```
[Try it online!](https://tio.run/##K6gsycjPM/6fZhvzPycxNyklUSHPKjpaqygxLz1VI1PbUMdAR9dQMzYtv0ghUyEzTwEikacZ@7@gKDOvRCNNw0RT8z8A "Python 3 – Try It Online")
[Answer]
# [GolfScript](http://www.golfscript.com/golfscript/), 12 (13) bytes
```
,{)),(;-1%}%`
```
```
,{)),(;-1%}%` #Reversed iota of iota
,             #0 to n-1 iota
 {        }%  #For each element in the iota
 {))      }   #Increment by 2
 {  ,     }   #Iota
 {   (;   }   #Pop leading 0
 {     -1%}   #Reverse it
            ` #Pretty output, not needed if you use a better stack-interpreter
```
[Try it online!](https://tio.run/##S8/PSStOLsosKPlv8V@nWlNTR8Na11C1VjXh/38A "GolfScript – Try It Online")
Below is my old solution, I gained inspiration after posting and improved it.
```
),(;{),(;-1%}%`
```
Comma is the function that builds an array 0 to n-1, "iota expand".
```
),(;{),(;-1%}%` #Take in a number, output reversed expanded iota
)               #Increment input by 1
 ,              #Iota expand
  (;            #Remove leading 0
    {       }%  #For every element, do the following
    {)      }   #Increment by 1
    { ,     }   #Iota expand
    {  (;   }   #Remove leading 0
    {    -1%}   #Reverse
              ` #Pretty output; technically not needed
```
[Try it online!](https://tio.run/##S8/PSStOLsosKPlv8V9TR8O6GkToGqrWqib8/w8A "GolfScript – Try It Online")
[Answer]
# [Factor](https://factorcode.org/), 45 bytes
```
: f ( n -- s ) [1,b] [ 1 [a,b] >array ] map ;
```
[Try it online!](https://tio.run/##HcwxC8IwEIbhvb/iGxVMoYNLCq7SpYPiFDqc9aodTOPdKfTXx@j2DC/vRKMtki/nrj96kAitiifZoxaKd1Yov94cx6IkbLYmmaOhrbre48QfFuWbmxejKntM2CDCOSi2CM3uOiCgQaCfDv87hrJPaPO@1HX@Ag "Factor – Try It Online")
[Answer]
# [Ruby](https://www.ruby-lang.org/), ~~34~~ 30 bytes
```
->n,*a{(1..n).map{|x|a=[x]+a}}
```
[Try it online!](https://tio.run/##KypNqvyfZvtf1y5PRyuxWsNQTy9PUy83saC6pqIm0Ta6IlY7sbb2f4FCWrRJ7H8A "Ruby – Try It Online")
Thanks Value Ink (as usual) for -4 bytes.
[Answer]
# [Haskell](https://www.haskell.org/), 27 bytes
```
f n=scanl(flip(:))[1][2..n]
```
[Answer]
# [Zsh](https://www.zsh.org/), 22 bytes
```
eval echo {{1..$1}..1}
```
[Try it online!](https://tio.run/##qyrO@J@moanxP7UsMUchNTkjX6G62lBPT8WwVk/PsPa/JhdXmoIhEBsBsTEQm4Bog/8A "Zsh – Try It Online")
`{{1..$1}..1}` -> `{1..1} {2..1} {3..1} {4..1} ...`
`eval echo {1..1} {2..1} {3..1} ...` -> `echo 1 2 1 3 2 1 ...`
If the sublists must be delimited, then [25 bytes for `,`](https://tio.run/##qyrO@J@moanBVZxaoqBb8T@1LDFHITU5I1@hutpQT0/FsFZPz7A2RkHnvyYXV5qCIRAbAbExEJv8BwA "Zsh – Try It Online") or [26 bytes for newline](https://tio.run/##qyrO@J@moanxvyi1IDWxREHFUCE1OSNfoVolWls7M1ZPz7D2vyYXV5qCIRAbAbExEJuAaAOu/wA "Zsh – Try It Online").
[Answer]
# [Fortran (GFortran)](https://gcc.gnu.org/fortran/), 47 bytes
```
read*,i
print*,("{",(j,j=k,1,-1),"}",k=1,i)
end
```
[Try it online!](https://tio.run/##S8svKilKzNNNT4Mw/v8vSk1M0dLJ5Cooyswr0dLRUKpW0tHI0smyzdYx1NE11NRRqlXSybY11MnU5ErNS/n/3wQA "Fortran (GFortran) – Try It Online")
Could remove 8 chars by getting rid of printed brackets if anyone would believe that they are lists otherwise.
[Answer]
# [Elm](https://elm-lang.org/), 45 bytes
```
r=List.range 1
f=List.map(List.reverse<<r)<<r
```
[Try it on Ellie](https://ellie-app.com/kR8mY5cqZkya1)
[Answer]
# [Arturo](https://arturo-lang.io), ~~22~~ 18 bytes
```
$=>[map&=>[@&..1]]
```
[Try it](http://arturo-lang.io/playground?yBKvvi)
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 5 bytes
```
⟦₁⟧₁ᵐ
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/r//9H8ZY@aGh/NXw4kH26d8P@/yf8oAA "Brachylog – Try It Online")
### Explanation
```
⟦₁     Ascending range from 1 to the input
    ᵐ  Map:
  ⟧₁     Descending range from 1 to the mapped element
```
[Answer]
## Haskell, 74 73 51 bytes
`main=do i<-getLine;print[[x,x-1..1]|x<-[1..read i]]`
[Try it online!](https://tio.run/##y0gszk7Nyfn/PzcxM882JV8h00Y3PbXEJzMv1bqgKDOvJDq6QqdC11BPzzC2psJGNxrIKkpNTFHIjI39/98EAA)
-22 bytes thanks to @79037662
[Answer]
# [Burlesque](https://github.com/FMNSSun/Burlesque), 9 bytes
```
riroq<-pa
```
[Try it online!](https://tio.run/##SyotykktLixN/f@/KLMov9BGtyDx/38TAA "Burlesque – Try It Online")
```
ri  # Read int
ro  # Range [1,N]
q<- # Boxed reverse
pa  # Operate over ((1), (1 2), (1 2 3),...)
```
Alternative 9 byter, but this also has an empty list as the first element:
```
riroiT)<-
```
[Answer]
# [Go](https://go.dev), 105 bytes
```
func(n int)(o[][]int){for i:=1;i<=n;i++{J:=[]int{}
for j:=i;j>0;j--{J=append(J,j)}
o=append(o,J)}
return}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=NU69CsIwGNzzFMEpoa0oOEhjfIBM7qVDqE1JtF9CSF1Cn8SlCD6GD9K3sT863R133N3z1dhhxE5WN9nUuJUakG6d9WG7UW3YoIf0WPF3F1R2HLXqoCKANQRKbFEW5cyish7rnO-ZPnFgOkmiyPnixR7Npsm5Zua8YybLouDSuRquRKSG9sj-pU3FJH0dOg_9OviZ95ZThOKILn6qvANR5EAp-mWGYcUv)
[Answer]
# shell with `seq` loop, 46 bytes
```
for n in `seq $1`;do seq -s\  -t'\n' $n 1;done
```
[Answer]
# JavaScript, 60 bytes
Without recursion:
```
n=>eval('for(a=[];n;a[--n]=b)for(b=[j=n];j-->1;b[n-j]=j);a')
```
Try it:
```
f=n=>eval('for(a=[];n;a[--n]=b)for(b=[j=n];j-->1;b[n-j]=j);a')
console.log(JSON.stringify(f(1)));
console.log(JSON.stringify(f(2)));
console.log(JSON.stringify(f(3)));
console.log(JSON.stringify(f(4)));
```
]