Anonymous user
Pascal's triangle: Difference between revisions
m
→using a lazy sequence generator: add newlines
(→using a lazy sequence generator: show a version with implicit $_, which I think looks better in this case.) |
m (→using a lazy sequence generator: add newlines) |
||
Line 2,829:
The following routine returns a lazy list of lines using the sequence operator (<tt>...</tt>). With a lazy result you need not tell the routine how many you want; you can just use a slice subscript to get the first N lines:
<lang perl6>sub pascal {
[1], { [0, |$_ Z+ |$_, 0] } ... *
}
.say for pascal[^10];</lang>
|