Pascal's triangle: Difference between revisions

m
(→‎using a lazy sequence generator: show a version with implicit $_, which I think looks better in this case.)
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] } ... * }
[1], { [0, |$_ Z+ |$_, 0] } ... *
}
.say for pascal[^10];</lang>
Anonymous user