Perl 6: The difference between ... and ...?

What is the difference between ... and ... in Perl 6?

For example, the following lines will produce the same result:

for 1..5 { .say }; for 1...5 { .say }; 
+5
source share
1 answer

.. construct a range object (think of a mathematical interval).

... builds a sequence (think of a lazily generated disposable list).

If all I want to do is iterate over consecutive integers (for example, for indexing), I would prefer it to be the same (this is a less general tool and the character is shorter to load).

If you need more precise control, use the latter (for example, the idiomatic example for generating a Fibonacci sequence in Perl6 is given by the expression 1, 1, *+* ... * , where the third term *+* is the rule of inductive element generation).

+10
source

Source: https://habr.com/ru/post/1276069/


All Articles