In Channel§
See primary documentation in context for method list
method list(Channel:)
Returns a list based on the Seq
which will iterate items in the queue and remove each item from it as it iterates. This can only terminate once the close
method has been called.
my = Channel.new; .send(1); .send(2);.close;say .list; # OUTPUT: «(1 2)»
In role Blob§
See primary documentation in context for method list
multi method list(Blob:)
Returns a List
of integers:
say "zipi".encode("ascii").list; # OUTPUT: «(122 105 112 105)»
In Supply§
See primary documentation in context for method list
multi method list(Supply:)
Taps the Supply
it is called on, and returns a lazy list that will be reified as the Supply
emits values. The list will be terminated once the Supply
is done
. If the Supply
quit
s, then an exception will be thrown once that point in the lazy list is reached.
In Failure§
See primary documentation in context for method list
multi method list(Failure:)
Marks the failure as handled and throws the invocant's exception.
In Capture§
See primary documentation in context for method list
method list(Capture:)
Returns the positional part of the Capture
.
my Capture = \(2, 3, 5, apples => (red => 2));say .list; # OUTPUT: «(2 3 5)»
In role QuantHash§
See primary documentation in context for method list
multi method list(QuantHash:)
Returns a list of Pair
objects of all keys and values in the QuantHash.
In role PositionalBindFailover§
See primary documentation in context for method list
multi method list(::?CLASS:)
Returns a List
based on the iterator
method without caching it.
In Any§
See primary documentation in context for method list
multi method list(Any:)multi method list(Any \SELF:)
Applies the infix ,
operator to the invocant and returns the resulting List
:
say 42.list.^name; # OUTPUT: «List»say 42.list.elems; # OUTPUT: «1»
Subclasses of Any
may choose to return any core type that does the Positional
role from .list
. Use .List
to coerce specifically to List
.
@
can also be used as a list or Positional
contextualizer:
my = $[1,2,3];say .raku; # OUTPUT: «$[1, 2, 3]»my = @;say .^name; # OUTPUT: «Array»
In the first case, the list is itemized. @
as a prefix puts the initial scalar in a list context by calling .list
and turning it into an Array
.
In Map§
See primary documentation in context for method list
multi method list(Map: --> List)
Returns a List
of Pair
objects of all keys and values in the Map.
my = Map.new('a' => (2, 3), 'b' => 17);say .list; # OUTPUT: «(b => 17 a => (2 3))»
In role Buf§
See primary documentation in context for method list
multi method list(Buf:)
Returns a List
of integers.
say Buf.new(122,105,112,205).list; # OUTPUT: «(122 105 112 205)»
In Uni§
See primary documentation in context for method list
method list(Uni:)
Returns a Seq
of integer codepoints.
In Range§
See primary documentation in context for method list
multi method list(Range:)
Generates the list of elements that the range represents.
say (1..5).list; # OUTPUT: «(1 2 3 4 5)»say (1^..^5).list; # OUTPUT: «(2 3 4)»
In Match§
See primary documentation in context for method list
Returns a list of positional submatches.
In List§
See primary documentation in context for routine list
multi list(+list)multi method list(List:)
The method just returns the invocant self. The subroutine adheres to the single argument rule: if called with a single argument that is a non-itemized Iterable
it returns a List
based on the argument's iterator; otherwise it just returns the argument list.
For example:
my = (1, 2); # an itemized Listput .list.raku; # OUTPUT: «(1, 2)»put list().raku; # OUTPUT: «($(1, 2),)»put list(|).raku; # OUTPUT: «(1, 2)»
The last statement uses the prefix:<|>
operator to flatten the tuple into an argument list, so it is equivalent to:
put list(1, 2).raku; # OUTPUT: «(1, 2)»
There are other ways to list the elements of an itemized single argument. For example, you can decontainerize the argument or use the @
list contextualizer:
put list(<>).raku; # OUTPUT: «(1, 2)»put list(@).raku; # OUTPUT: «(1, 2)»
Note that converting a type object to a list may not do what you expect:
put List.list.raku; # OUTPUT: «(List,)»
This is because the .list
candidate accepting a type object as the invocant is provided by Any
. That candidate returns a list with one element: the type object self. If you're developing a collection type whose type object should be a valid representation of an empty collection, you may want to provide your own candidate for undefined invocants or override the Any:
candidates with an "only" method. For example:
mymy LinkedList ; # an empty linked listput .list.raku; # OUTPUT: «()»
In Backtrace§
See primary documentation in context for method list
multi method list(Backtrace:)
Returns a list of Backtrace::Frame
objects for this backtrace.