Camelia
Prev: Reduction operators

Reduction Triangle operators

The ~ in front of the operator is only needed for the stringification of the list to inject spaces between the values when printed.

examples/arrays/triangle_operators.p6
#!/usr/bin/env perl6
use v6;

say ~[\+] 1..5;  # 1 3 6 10 15
say ~[\*] 1..5;  # 1 2 6 24 120

Output

examples/arrays/triangle_operators.p6.out
1 3 6 10 15
1 2 6 24 120

Prev: Reduction operators

Table of Contents

Comments

In the comments, please wrap your code snippets within <pre> </pre> tags and use spaces for indentation.
comments powered by Disqus

Perl 6 Tricks and Treats newsletter

Register to the free newsletter now, and get updates and news.
Email:
Name: