Post History
BQN, 7 6 bytesSBCS ≢↑∘⊢´↕ Run online! The less-golfed version {↑⍟𝕩⟨⟩} is more readable: it applies Prefixes (↑) the given number of times to the empty list ⟨⟩ and… that's it. (Suffixes also wo...
Answer
#2: Post edited
# [BQN](https://mlochbaum.github.io/BQN/), 7 bytes<sup>[SBCS](https://github.com/mlochbaum/BQN/blob/master/commentary/sbcs.bqn)</sup>- ```
{↑⍟𝕩⟨⟩}- ```
[Run online!](https://mlochbaum.github.io/BQN/try.html#code=U2V0IOKGkCB74oaR4o2f8J2VqeKfqOKfqX0KCuKJjcuY4p+cKFNldMKoKSDihpU0)Stumbled on this one a little while ago. This function applies [Prefixes](https://mlochbaum.github.io/BQN/doc/prefixes.html) the given number of times to the empty list `⟨⟩` and… that's it. (Suffixes also works, placing elements in the opposite order). The reason this works is that a prefix of a set-number is also a set-number, so that the values of the prefixes for `n` range from the empty prefix `0` to the complete prefix `n`. This list is defined to be `n+1`.
- # [BQN](https://mlochbaum.github.io/BQN/), <strike>7</strike> 6 bytes<sup>[SBCS](https://github.com/mlochbaum/BQN/blob/master/commentary/sbcs.bqn)</sup>
- ```
- ≢↑∘⊢´↕
- ```
- [Run online!](https://mlochbaum.github.io/BQN/try.html#code=U2V0IOKGkCB74oaR4o2f8J2VqeKfqOKfqX0KU2V0IOKGqSDiiaLihpHiiJjiiqLCtOKGlQoK4omNy5jin5woU2V0wqgpIOKGlTQ=)
- The less-golfed version `{↑⍟𝕩⟨⟩}` is more readable: it applies [Prefixes](https://mlochbaum.github.io/BQN/doc/prefixes.html) (`↑`) the given number of times to the empty list `⟨⟩` and… that's it. (Suffixes also works, placing elements in the opposite order). The reason this works is that a prefix of a set-number is also a set-number, so that the values of the prefixes for `n` range from the empty prefix `0` to the complete prefix `n`. This list is defined to be `n+1`.
- The golfed version uses [Fold](https://mlochbaum.github.io/BQN/doc/fold.html) (`´`) and some other tricks to turn the computation into a 3-[train](https://mlochbaum.github.io/BQN/doc/train.html): something that doesn't work well with Repeat (`⍟`) because the number needs to be an operand.
- ```
- ≢↑∘⊢´↕
- ↕ # Range: a list with length given by the argument
- ≢ # Shape: an empty list as the argument has no axes
- ´ # Fold over the range, starting with the shape
- ↑ # Prefixes
- ∘⊢ # Of the right argument
- ```
#1: Initial revision
# [BQN](https://mlochbaum.github.io/BQN/), 7 bytes<sup>[SBCS](https://github.com/mlochbaum/BQN/blob/master/commentary/sbcs.bqn)</sup> ``` {↑⍟𝕩⟨⟩} ``` [Run online!](https://mlochbaum.github.io/BQN/try.html#code=U2V0IOKGkCB74oaR4o2f8J2VqeKfqOKfqX0KCuKJjcuY4p+cKFNldMKoKSDihpU0) Stumbled on this one a little while ago. This function applies [Prefixes](https://mlochbaum.github.io/BQN/doc/prefixes.html) the given number of times to the empty list `⟨⟩` and… that's it. (Suffixes also works, placing elements in the opposite order). The reason this works is that a prefix of a set-number is also a set-number, so that the values of the prefixes for `n` range from the empty prefix `0` to the complete prefix `n`. This list is defined to be `n+1`.