See Original text in context
method is-deterministic(Iterator: --> Bool)
Should return True
for iterators that, given a source, will always produce the values in the same order.
Built-in operations can perform certain optimizations when it is certain that values will always be produced in the same order. Some examples:
say (1..10).iterator.is-deterministic; # OUTPUT: «True»say (1..10).roll(5).iterator.is-deterministic; # OUTPUT: «False»say %(a => 42, b => 137).iterator.is-deterministic; # OUTPUT: «False»
The Iterator role implements this method returning True
, indicating an iterator that will always produce values in the same order.