where that just says "make an arbitrarily long list of 1's and reduce them using concatenation (the ~ operator), returning partial results in a list". That even works today in pugs if you replace the * with, say, 10:[\~] 1 xx *
Or using the new, spiffily readable ... infix, it's even shorter:pugs> .say for [\~] 1 xx 10 1 11 111 1111 11111 111111 1111111 11111111 111111111 1111111111
That just extends the list on the left by concatenating a 1 onto the previous last value of the list. But nobody has implemented that one yet, since we only invented it on Sunday... :)1...{$_~1}
The cool thing about it is that (if you're not golfing it) you can write however much of the list you like as an example for the human reader, and give the parameter a better name:
1,11,111,1111 ... {$^previous ~ 1}
Update: nowadays (2010/04/03) the closure goes on the left, so we'd write those more like:
1,*~1...* 1, 11, 111, 1111, {$^previous ~ 1} ... *
In reply to Re^2: Generate the perl sequence 1, 11, 111, ....
by TimToady
in thread Generate the perl sequence 1, 11, 111, ....
by alih110
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |