Ascending Pea Pattern generator For those who are not familiarized with the Pea Pattern, it is a simple mathematical pattern.

There are multiple variations of this pattern, but we will focus in one:


  Ascending  Pea Pattern


It looks like this:

1
11
21
1112
3112
211213
...


It seems really hard to get the following line, but it is really easy. The way to get the next line is by counting the number of times a digit have repeated on the previous line (start counting with the lowest, to largest):

one
one one
two ones
one one, one two
three ones, one two
two ones, one two, one three
...


Requirements/Rules:


We will start at 1
It will be a snippet
There must be a way to specify the number of lines generates (e.g 5
will give the first 5 lines)
The code should be as short as possible
It must start counting from lowest to largest (the Ascending
variation)
APL, 32 characters
⍪⌽({⍵,⍨,/{⌽⍵,+/⍵⍷d}¨⍳⌈/d←⊃⍵}⍣⎕)1

This generates lines starting from 0 (i.e. 0 generates 1, 1 generates 1 followed by 1 1, etc.), as specified by user input. I used Dyalog APL for this, and ⎕IO should be set to its default of 1.
Example:
      ⍪⌽({⍵,⍨,/{⌽⍵,+/⍵⍷d}¨⍳⌈/d←⊃⍵}⍣⎕)1
⎕:
      0
1

      ⍪⌽({⍵,⍨,/{⌽⍵,+/⍵⍷d}¨⍳⌈/d←⊃⍵}⍣⎕)1
⎕:
      13
               1 
             1 1 
             2 1 
         1 1 1 2 
         3 1 1 2 
     2 1 1 2 1 3 
     3 1 2 2 1 3 
     2 1 2 2 2 3 
     1 1 4 2 1 3 
 3 1 1 2 1 3 1 4 
 4 1 1 2 2 3 1 4 
 3 1 2 2 1 3 2 4 
 2 1 3 2 2 3 1 4 
 2 1 3 2 2 3 1 4

Once I get some more time, I'll write up an explanation. ⍨