user
The   Look and say sequence   is a recursively defined sequence of numbers studied most notably by   John Conway.

The   **look-and-say sequence**   is also known as the   **Morris Number Sequence**,   after cryptographer Robert Morris,   and the puzzle   *What is the next number in the sequence 1,   11,   21,   1211,   111221?*   is sometimes referred to as the *Cuckoo's Egg*,   from a description of Morris in Clifford Stoll's book   *The Cuckoo's Egg*.

**Sequence Definition**

* Take a decimal number
* *Look* at the number, visually grouping consecutive runs of the same digit.
* *Say* the number, from left to right, group by group; as how many of that digit there are - followed by the digit grouped.

:   This becomes the next number of the sequence.

**An example:**

* Starting with the number 1,   you have *one* 1 which produces 11
* Starting with 11,   you have *two* 1's.   I.E.:   21
* Starting with 21,   you have *one* 2, then *one* 1.   I.E.:   (12)(11) which becomes 1211
* Starting with 1211,   you have *one* 1, *one* 2, then *two* 1's.   I.E.:   (11)(12)(21) which becomes 111221

Task

Write a program to generate successive members of the look-and-say sequence.

Related tasks

* Fours is the number of letters in the ...
* Number names
* Self-describing numbers
* Self-referential sequence
* Spelling of ordinal numbers

See also

* Look-and-Say Numbers (feat John Conway), A Numberphile Video.
* This task is related to, and an application of, the Run-length encoding task.
* Sequence A005150 on The On-Line Encyclopedia of Integer Sequences.
assistant
(formerly Perl 6)

**Works with**: rakudo version 2018.03

In Raku it is natural to avoid explicit loops; rather we use the sequence operator to define a lazy infinite sequence. We'll print the first 15 values here.

```
.say for ('1', *.subst(/(.)$0*/, { .chars ~ .[0] }, :g) ... *)[^15];
```

Output:

```
1
11
21
1211
111221
312211
13112221
1113213211
31131211131221
13211311123113112211
11131221133112132113212221
3113112221232112111312211312113211
1321132132111213122112311311222113111221131221
11131221131211131231121113112221121321132132211331222113112211
311311222113111231131112132112311321322112111312211312111322212311322113212221
```