routine eager

Documentation for routine eager assembled from the following types:

class Any

From Any

(Any) method eager

Defined as:

method eager() is nodal

Interprets the invocant as a List, evaluates it eagerly, and returns that List.

my  $range = 1..5;
say $range;         # OUTPUT: «1..5␤» 
say $range.eager;   # OUTPUT: «(1 2 3 4 5)␤»

class Seq

From Seq

(Seq) method eager

method eager(Seq:D: --> List:D)

Returns an eagerly evaluated List based on the invocant sequence, and marks it as consumed. If called on an already consumed sequence, throws an error of type X::Seq::Consumed.

my $s = lazy 1..5;
say $ OUTPUT: «True␤» 
say $s.eager;   # OUTPUT: «(1 2 3 4 5)␤» 
say $s.eager;
    when X::Seq::Consumed {
        say 'Throws exception if already consumed';
# OUTPUT: «Throws exception if already consumed␤»

class List

From List

(List) routine eager

Defined as:

multi method eager(List:D: --> List:D)
multi sub eager(*@elems --> List:D)

Evaluates all elements in the List eagerly, and returns them as a List.

my  \ll = (lazy 1..5).cache;
say ll[];     # OUTPUT: «(...)␤» 
say ll.eager  # OUTPUT: «(1 2 3 4 5)␤»