Write a “Look-and-Say Numbers” generator [duplicate]

This question already has an answer here:

There is a sequence of numbers called the "Look-and-Say Numbers".

Here is an example of the first 5 terms of the sequence, starting at 1 (with spaces added between the digits):

1
1 1
2 1
1 2 1 1
1 1 1 2 2 1

The pattern is simple, once you see it.

The sequence starts with 1. There is one 1, so the next number is 11 (as in one of the number 1).

In this number, there are 2 1s, so the next number is 21.

In this number there is 1 2, and 1 1, so the next number is 1211.

In this number there is 1 1, followed by 1 2, followed 2 1s - so the number is 111221.

You must write a program that generates the first n terms of this sequence, where n is given by stdin. The sequence will start at 1.

This is a code-golf task, so shortest code wins.

marked as duplicate by Calvin's Hobbies, Peter Taylor, Level River St, Howard code-golf StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Aug 12 '14 at 12:03

• @Calvin'sHobbies The linked question has an additional restriction, but that restriction is quite trivial in practice. Therefore I am voting to close as a duplicate. – Level River St Aug 12 '14 at 11:59

Mathematica, 68 bytes

There's no STDIN in Mathematica, so here is a function instead

s=FromDigits/@NestList[Flatten[Reverse@@@Tally/@Split[#]]&,{1},#-1]&

Usage:

s

> {1, 11, 21, 1211, 111221}
• Isn't Input[] STDIN? – DavidC Aug 12 '14 at 13:01
• @DavidCarraher Well, it's kinda STDIN but parses and interprets the input right away, right? – Martin Ender Aug 12 '14 at 13:02
• Good point. And InputString[] avoids parsing but interprets all input as strings. – DavidC Aug 12 '14 at 13:22