Rules / Types, classes & roles / basic

Any Reference

Thing/object

What it is #

Position in the hierarchy #

Inherits from
Does
Inherited byMetamodel::Primitives, Scalar, Variable, Proxy, Cool

Routines #

Signatures are reproduced from the documentation, including their declared return types. A routine listed here is part of the type's published interface; whether Raku++ implements it is a separate question, answered by the examples below.

method ACCEPTS #

multi method ACCEPTS(Any:D: Mu $other)

Usage: Returns True if $other === self (i.e. it checks object identity). Many built-in types override this for more specific comparisons.

routine any #

method any(        --> Junction:D)
multi  any(+values --> Junction:D)
multi  any(@values --> Junction:D)

Returns Junction:D.

Interprets the invocant or arguments as a list and creates an any-Junction from it.

routine all #

method all(        --> Junction:D)
multi  all(+values --> Junction:D)
multi  all(@values --> Junction:D)

Returns Junction:D.

Interprets the invocant or arguments as a list and creates an all-Junction from it.

routine one #

method one(        --> Junction:D)
multi  one(+values --> Junction:D)
multi  one(@values --> Junction:D)

Returns Junction:D.

Interprets the invocant or arguments as a list and creates a one-Junction from it.

routine none #

method none(        --> Junction:D)
multi  none(+values --> Junction:D)
multi  none(@values --> Junction:D)

Returns Junction:D.

Interprets the invocant or arguments as a list and creates a none-Junction from it.

method list #

multi method list(Any:U:)
multi method list(Any:D \SELF:)

Applies the infix , operator to the invocant and returns the resulting List: 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:

method push #

multi method push(Any:U \SELF: |values --> Positional:D)

Returns Positional:D.

The method push is defined for undefined invocants and allows for autovivifying undefined to an empty Array, unless the undefined value implements Positional already. The argument provided will then be pushed into the newly created Array.

routine reverse #

multi        reverse(*@list  --> Seq:D)
multi method reverse(List:D: --> Seq:D)

Returns Seq:D.

Returns a Seq with the same elements in reverse order. Note that reverse always refers to reversing elements of a list; to reverse the characters in a string, use flip. Examples:

method sort #

multi method sort()
multi method sort(&custom-routine-to-use)

Sorts iterables with cmp or given code object and returns a new Seq. Optionally, takes a Callable as a positional parameter, specifying how to sort. Examples:

routine map #

multi method map(\SELF: &code)
multi        map(&code, +values)

map will iterate over the invocant and apply the number of positional parameters of the code object from the invocant per call. The returned values of the code object will become elements of the returned Seq. The additional parameters :$label and :$item, available in the method form, are useful only internally, since for loops get converted to maps. The :$label takes an existing Label to

routine deepmap #

method deepmap(&block --> Iterable) is nodal
sub    deepmap(&op, \obj --> Iterable)

Returns Iterable.

deepmap will apply its argument (or first argument for the sub form) to each element and return a new Iterable with the return values of the argument, unless the element does the Iterable role. For those elements deepmap will descend recursively into the sublist. In the case of Associatives, it will be applied to its values:

routine duckmap #

method duckmap(&block --> Iterable) is rw is nodal
sub    duckmap(&op, \obj --> Iterable)

Returns Iterable.

duckmap will apply its argument (or first argument for the sub form) to each element that behaves in such a way that the argument can be applied. If it fails, it will descend recursively if possible, or otherwise return the item without any transformation. It will act on values if the object is Associative. In the first case, it is applied to c, d and e which are the ones that

routine nodemap #

method nodemap(&block --> Iterable) is nodal
sub    nodemap(&op, \obj --> Iterable)

Returns Iterable.

nodemap will apply its argument (or first argument for the sub form) to each element and return a new Iterable with the return values of its Callable argument. In contrast to deepmap it will not descend recursively into sublists if it finds elements which do the Iterable role. The examples above would have produced the exact same results if we had used

method flat #

method flat() is nodal

Interprets the invocant as a list, flattens non-containerized Iterables into a flat list, and returns that list. Keep in mind Map and Hash types are Iterable and so will be flattened into lists of pairs. Note that Arrays containerize their elements by default, and so flat will not flatten them. You can use the

method eager #

method eager() is nodal

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

routine elems #

multi method elems(Any:U: --> 1)
multi method elems(Any:D:)
multi        elems($a)
multi        elems(array:D \a)

Returns 1.

Interprets the invocant or argument as a list, and returns the number of elements in the list. It will also return 1 for classes.

routine end #

multi method end(Any:U: --> 0)
multi method end(Any:D:)
multi        end($a)
multi        end(array:D \a)
multi        end($, *%)

Returns 0.

Interprets the invocant or argument as a list, and returns the last index of that list.

method pairup #

multi method pairup(Any:U:)
multi method pairup(Any:D:)

Returns an empty Seq if the invocant is a type object Interprets the invocant as a list, and constructs a list of Pairs from it, in the same way that assignment to a Hash does. That is, it takes two consecutive elements and constructs a pair from them, unless the item in the key position already is a pair (in which case the pair is passed through, and the next list item, if any,

method Array #

method Array(--> Array:D) is nodal

Returns Array:D.

Coerces the invocant to an Array.

method List #

method List(--> List:D) is nodal

Returns List:D.

Coerces the invocant to List, using the list method.

method serial #

multi method serial()

This method is Rakudo specific, and is not included in the Raku spec. The method returns the self-reference to the instance itself: This is apparently a no-op, as exemplified by the third example above. However, in HyperSeqs and RaceSeqs it returns a serialized Seq, so it can be considered the opposite of the hyper/race methods. As such, it ensures that we are in serial list-processing mode, as

method Hash #

multi method Hash( --> Hash:D)

Returns Hash:D.

Coerces the invocant to Hash.

method hash #

multi method hash(Any:U:)
multi method hash(Any:D:)

When called on a type object, returns an empty Hash. On instances, it is equivalent to assigning the invocant to a %-sigiled variable and returning that. Subclasses of Any may choose to return any core type that does the Associative role from .hash. Use .Hash to coerce specifically to Hash.

method Slip #

method Slip(--> Slip:D) is nodal

Returns Slip:D.

Coerces the invocant to Slip.

method Map #

method Map(--> Map:D) is nodal

Returns Map:D.

Coerces the invocant to Map.

method Seq #

method Seq() is nodal

Coerces the invocant to Seq.

method Bag #

method Bag(--> Bag:D) is nodal

Returns Bag:D.

Coerces the invocant to Bag, whereby Positionals are treated as lists of values.

method BagHash #

method BagHash(--> BagHash:D) is nodal

Returns BagHash:D.

Coerces the invocant to BagHash, whereby Positionals are treated as lists of values.

method Set #

method Set(--> Set:D) is nodal

Returns Set:D.

Coerces the invocant to Set, whereby Positionals are treated as lists of values.

method SetHash #

method SetHash(--> SetHash:D) is nodal

Returns SetHash:D.

Coerces the invocant to SetHash, whereby Positionals are treated as lists of values.

method Mix #

method Mix(--> Mix:D) is nodal

Returns Mix:D.

Coerces the invocant to Mix, whereby Positionals are treated as lists of values.

method MixHash #

method MixHash(--> MixHash:D) is nodal

Returns MixHash:D.

Coerces the invocant to MixHash, whereby Positionals are treated as lists of values.

method Supply #

method Supply(--> Supply:D) is nodal

Returns Supply:D.

First, it coerces the invocant to a list by applying its .list method, and then to a Supply.

routine min #

multi method min(&by?, :$k, :$v, :$kv, :$p )
multi        min(+args, :&by, :$k, :$v, :$kv, :$p)

Coerces the invocant to Iterable and returns the smallest element using cmp semantics; in the case of Maps and Hashes, it returns the Pair with the lowest value. A Callable positional argument can be given to the method form. If that Callable accepts a single argument, then it

routine max #

multi method max(&by?, :$k, :$v, :$kv, :$p )
multi        max(+args, :&by, :$k, :$v, :$kv, :$p)

The interface of the max method / routine is the same as the one of min. But instead of the lowest value, it will return the highest value. As of the 2023.08 Rakudo compiler release:

routine minmax #

multi method minmax()
multi method minmax(&by)
multi        minmax(+args, :&by!)
multi        minmax(+args)

Returns a Range from the smallest to the largest element. If a Callable positional argument is provided, each value is passed into the filter, and its return value is compared instead of the original value. The original values are still used in the returned Range. In sub form, the invocant is passed as an argument and a comparison Callable

method minpairs #

multi method minpairs(Any:D:)

Calls .pairs and returns a Seq with all of the Pairs with minimum values, as judged by the cmp operator:

method maxpairs #

multi method maxpairs(Any:D:)

Calls .pairs and returns a Seq with all of the Pairs with maximum values, as judged by the cmp operator:

method keys #

multi method keys(Any:U: --> List)
multi method keys(Any:D: --> List)

Returns List.

For defined Any returns its keys after calling list on it, otherwise calls list and returns it. See also List.keys. Trying the same on a class will return an empty list, since most of them don't really have keys.

method flatmap #

method flatmap(&block, :$label)

Convenience method, analogous to .map(&block).flat.

method roll #

multi method roll(--> Any)
multi method roll($n --> Seq)

Returns Any or Seq.

Coerces the invocant to a list by applying its .list method and uses List.roll on it. $m, in this case, is converted into a list and then a (weighted in this case) dice is rolled on it. See also List.roll for more information.

method iterator #

multi method iterator(Any:)

Returns the object as an iterator after converting it to a list. This is the function called from the for statement. An iterable subclass of Any should provide its own implementation of this method, but other classes can inherit this as-is to provide a single-item-list iterator in contexts that require one.

method pick #

multi method pick(--> Any)
multi method pick($n --> Seq)

Returns Any or Seq.

Coerces the invocant to a List by applying its .list method and uses List.pick on it.

routine skip #

multi method skip()
multi method skip(Whatever)
multi method skip(Callable:D $w)
multi method skip(Int() $n)
multi method skip($skip, $produce)

Creates a Seq from 1-item list's iterator and uses Seq.skip on it, please check that document for real use cases; calling skip without argument is equivalent to skip(1). As of release 2022.07 of the Rakudo compiler, there is also a "sub" version of skip. It must have the skip specifier as the first argument. The rest of the arguments are turned into a Seq and then have the skip

method are #

multi method are(Any:)
multi method are(Any: Any $type)

The argumentless version available as of release 2022.02 of the Rakudo compiler. The version with the type argument is in the 6.e language version (early implementation exists in Rakudo compiler 2024.05+). If called without arguments, returns the strictest type (or role) to which all elements of the list will smartmatch. Returns Nil on an empty list. Scalar values are interpreted as a single element list.

method prepend #

multi method prepend(Any:U: --> Array)
multi method prepend(Any:U: @values --> Array)

Returns Array.

Called with no arguments on an empty variable, it initializes it as an empty Array; if called with arguments, it creates an array and then applies Array.prepend on it.

method unshift #

multi method unshift(Any:U: --> Array)
multi method unshift(Any:U: @values --> Array)

Returns Array.

Initializes Any variable as empty Array and calls Array.unshift on it.

routine first #

multi method first(Bool:D $t)
multi method first(Regex:D $test, :$end, *%a)
multi method first(Callable:D $test, :$end, *%a is copy)
multi method first(Mu $test, :$end, *%a)
multi method first(:$end, *%a)
multi        first(Bool:D $t, |)
multi        first(Mu $test, +values, *%a)

In general, coerces the invocant to a list by applying its .list method and uses List.first on it. However, this is a multi with different signatures, which are implemented with (slightly) different behavior, although using it as a subroutine is equivalent to using it as a method with the second argument as the object. For starters, using a Bool as the argument will always return a Failure.

method unique #

multi method unique()
multi method unique( :&as!, :&with! )
multi method unique( :&as! )
multi method unique( :&with! )

Creates a sequence of unique elements either of the object or of values in the case it's called as a sub. The :as and :with parameters receive functions that are used for transforming the item before checking equality, and for checking equality, since by default the === operator is used: Please see unique for additional examples that use its sub form.

method repeated #

multi method repeated()
multi method repeated( :&as!, :&with! )
multi method repeated( :&as! )
multi method repeated( :&with! )

Similarly to unique, finds repeated elements in values (as a routine) or in the object, using the :as associative argument as a normalizing function and :with as equality function. It returns the last repeated element before normalization, as shown in the example above. See repeated for more examples that use its sub form.

method squish #

multi method squish( :&as!, :&with = &[===] )
multi method squish( :&with = &[===] )

Similar to .repeated, returns the sequence of first elements of contiguous sequences of equal elements, after normalization by the function :as, if present, and using as an equality operator the :with argument or === by default. As shown in the last example, a sequence can contain a single element. See squish for additional sub

method permutations #

method permutations(|c)

Coerces the invocant to a list by applying its .list method and uses List.permutations on it. Permutations of data structures with a single or no element will return a list containing an empty list or a list with a single element.

method join #

method join($separator = '') is nodal

Converts the object to a list by calling self.list, and calls .join on the list. Can take a separator, which is an empty string by default.

routine categorize #

multi method categorize()
multi method categorize(Whatever)
multi method categorize($test, :$into!, :&as)
multi method categorize($test, :&as)
multi        categorize($test, +items, :$into!, *%named )
multi        categorize($test, +items, *%named )

The first form will always fail. The second form classifies on the identity of the given object, which usually only makes sense in combination with the :&as argument. In its simplest form, it uses a $test whose result will be used as a key; the values of the key will be an array of the elements that produced that key as a result of the test. The :as argument will normalize before categorizing

routine classify #

multi method classify()
multi method classify(Whatever)
multi method classify($test, :$into!, :&as)
multi method classify($test, :&as)
multi        classify($test, +items, :$into!, *%named )
multi        classify($test, +items, *%named )

The first form will always fail. The second form classifies on the identity of the given object, which usually only makes sense in combination with the :&as argument. The rest include a $test argument, which is a function that will return a scalar for every input; these will be used as keys of a hash whose values will be arrays with the elements that output that key for the test function. Similarly to .categorize, elements can be

routine reduce #

multi method reduce(Any:U: & --> Nil)
multi method reduce(Any:D: &with)
multi        reduce (&with, +list)

Returns Nil.

This routine combines the elements in a list-y object, and produces a single result, by applying a binary subroutine. It applies its argument (or first argument for the sub form) as an operator to all the elements in the object (or second argument for the sub form), producing a single result. The subroutine must be either an infix operator or take two positional arguments. When using an infix operator, we must provide

routine produce #

multi method produce(Any:U: & --> Nil)
multi method produce(Any:D: &with)
multi        produce (&with, +list)

Returns Nil.

This is similar to reduce, but returns a list with the accumulated values instead of a single result. The last element of the produced list would be the output produced by the .reduce method. If it's a class, it will simply return Nil.

method pairs #

multi method pairs(Any:U:)
multi method pairs(Any:D:)

Returns an empty List if the invocant is a type object: For a value object, it converts the invocant to a List via the list method and returns the result of List.pairs on it. In this case, every element (with weight) in a bag is converted to a pair.

method antipairs #

multi method antipairs(Any:U:)
multi method antipairs(Any:D:)

Returns an empty List if the invocant is a type object If it's a value object, it returns the inverted list of pairs after converting it to a list of pairs; the values will become keys and the other way round.

method invert #

multi method invert(Any:U:)
multi method invert(Any:D:)

Applied to a type object will return an empty list; applied to an object will convert it to a list and apply List.invert to it, that is, interchange key with value in every Pair. The resulting list needs to be a list of Pairs. In this case, a Bag can be converted to a list of Pairs. If the result of converting the object to a list is not a list of pairs, the method will fail.

routine kv #

multi method kv(Any:U:)
multi method kv(Any:D:)
multi        kv($x)

Returns an empty List if the invocant is a type object: It calls list on the invocant for value objects and returns the result of List.kv on it as a list where keys and values will be ordered and contiguous In the case of Positionals, the indices will be considered keys.

method toggle #

method toggle(Any:D: *@conditions where .all ~~ Callable:D, Bool :$off  --> Seq:D)

Returns Seq:D.

Iterates over the invocant, producing a Seq, toggling whether the received values are propagated to the result on and off, depending on the results of calling Callables in @conditions: Imagine a switch that's either on or off (True or False), and values are produced if it's on. By default, the initial state of that switch is in "on"

routine head #

multi method head(Any:D:) is raw
multi method head(Any:D: Callable:D $w)
multi method head(Any:D: $n)

Returns either the first element in the object, or the first $n if that's used. In the first two cases, the results are different since there's no defined order in Mixes. In the other cases, it returns a Seq. A Callable can be used to return all but the last elements: As of release 2022.07 of the Rakudo compiler, there is also a "sub" version of head.

routine tail #

multi method tail() is raw
multi method tail($n)

Returns the last or the list of the $n last elements of an object. $n can be a Callable, usually a WhateverCode, which will be used to get all but the first n elements of the object. As of release 2022.07 of the Rakudo compiler, there is also a "sub" version of tail. It must have the tail specifier as the first argument. The rest of the arguments are turned into a Seq and then have the tail

method tree #

multi method tree(Any:U:)
multi method tree(Any:D:)
multi method tree(Any:D: Whatever )
multi method tree(Any:D: Int(Cool) $count)
multi method tree(Any:D: @ [&first, *@rest])
multi method tree(Any:D: &first, *@rest)

Returns the class if it's undefined or if it's not Iterable, returns the result of applying the tree method to its invocant otherwise. .tree has different prototypes for Iterable elements. With a number, it iteratively applies tree to every element in the lower level; the first instance will apply .tree(0) to every element in the array, and likewise for the next example.

method nl-out #

method nl-out(--> Str)

Returns Str.

Returns Str with the value of "\n". See IO::Handle.nl-out for the details.

method combinations #

method combinations(|c)

Coerces the invocant to a list by applying its .list method and uses List.combinations on it. Combinations on an empty data structure will return a list with a single element, an empty list; on a data structure with a single element it will return a list with two lists, one of them empty and the other with a single element.

method grep #

method grep(Mu $matcher, :$k, :$kv, :$p, :$v --> Seq)

Returns Seq.

Coerces the invocant to a list by applying its .list method and uses List.grep on it. For undefined invocants, based on $matcher the return value can be either ((Any)) or the empty List.

method append #

multi method append(Any:U \SELF: |values)

In the case the instance is not a positional-thing, it instantiates it as a new Array, otherwise clone the current instance. After that, it appends the values passed as arguments to the array obtained calling Array.append on it.

method values #

multi method values(Any:U:)
multi method values(Any:D:)

Will return an empty list for undefined or class arguments, and the object converted to a list otherwise.

method collate #

method collate()

The collate method sorts taking into account Unicode grapheme characteristics; that is, sorting more or less as one would expect instead of using the order in which their codepoints appear. collate will behave this way if the object it is applied to is Iterable. This method is affected by the $*COLLATION variable, which configures the four collation levels. While Primary, Secondary and

method cache #

method cache()

Provides a List representation of the object itself, calling the method list on the instance.

method batch #

multi method batch(Int:D $batch)
multi method batch(Int:D :$elems!)

Coerces the invocant to a list by applying its .list method and uses List.batch on it.

method rotor #

multi method rotor(Any:D: Int:D $batch, :$partial)
multi method rotor(Any:D: *@cycle, :$partial)

Creates a Seq that groups the elements of the object in lists of $batch elements. With the :partial named argument, it will also include lists that do not get to be the $batch size: .rotor can be called with an array of integers and pairs, which will be applied in turn. While integers will establish the batch size, as above, Pairs will use the key as batch size and the value as number of elements to

method sum #

method sum() is nodal

If the content is iterable, it returns the sum of the values after pulling them one by one, or 0 if the list is empty. It will fail if any of the elements cannot be converted to a number.

multi method #

method slice(Any:D: *@indices --> Seq:D)

Returns Seq:D.

Available as of the 2021.02 release of the Rakudo compiler. Converts the invocant to a Seq and then calls the slice method on it.

routine snip #

multi        snip(\matcher, +values)
multi method snip(\values: \matcher)

Available as of 6.e language version (early implementation exists in Rakudo compiler 2022.07+). The snip method / subroutine provides a way to cut a given Iterable into two or more Lists. A "snip" will be made as soon as the smartmatch of a value in the given Iterable returns False. The matcher may also be a list of matchers: as soon as a "snip" was made, will it start checking

routine snitch #

multi  snitch(\snitchee)
multi  snitch(&snitcher, \snitchee)
method snitch(\snitchee: &snitcher = &note)

Available as of 6.e language version (early implementation exists in Rakudo compiler 2022.12+). The snitch method / subroutine is a debugging / logging tool that will always return any invocant / argument given unchanged. By default, it will note the invocant / argument, but this can be overridden by specifying a Callable that is expected to take the invocant / argument as its only argument.

Examples, run three ways #

Every example below comes from the official documentation, together with the output that documentation asserts. Each was then executed by Rakudo and by Raku++ when this page was built. Where the three agree, one result is shown; where they do not, all three are — because which of them is wrong is exactly the information worth having.

11 all-differ · 4 doc-drift · 10 no-output · 1 not-runnable · 74 ok · 1 rakudo-differs · 5 rakupp-differs

class Any is Mu {}

Not executed: the documentation states no expected output for this example.

EXPR.ACCEPTS(EXPR);

Not executed: the documentation states no expected output for this example.

say so 2 == <1 2 3>.any;        # OUTPUT: «True␤»
say so 5 == any(<1 2 3>);       # OUTPUT: «False␤»
Output
True
False

Documentation, Rakudo and Raku++ all agree.

say so 3 < <2 3 4>.all;         # OUTPUT: «False␤»
say so 1 < all(<2 3 4>);        # OUTPUT: «True␤»
Output
False
True

Documentation, Rakudo and Raku++ all agree.

say so 1 == (1, 2, 3).one;      # OUTPUT: «True␤»
say so 1 == one(1, 2, 1);       # OUTPUT: «False␤»
Output
True
False

Documentation, Rakudo and Raku++ all agree.

say so 1 == (1, 2, 3).none;     # OUTPUT: «False␤»
say so 4 == none(1, 2, 3);      # OUTPUT: «True␤»
Output
False
True

Documentation, Rakudo and Raku++ all agree.

say 42.list.^name;           # OUTPUT: «List␤»
say 42.list.elems;           # OUTPUT: «1␤»
Output
List
1

Documentation, Rakudo and Raku++ all agree.

my $not-a-list-yet = $[1,2,3];
say $not-a-list-yet.raku;             # OUTPUT: «$[1, 2, 3]␤»
my @maybe-a-list = @$not-a-list-yet;
say @maybe-a-list.^name;              # OUTPUT: «Array␤»
Output
$[1, 2, 3]
Array

Documentation, Rakudo and Raku++ all agree.

my %h;
say %h<a>;     # OUTPUT: «(Any)␤»      <-- Undefined
%h<a>.push(1); # .push on Any
say %h;        # OUTPUT: «{a => [1]}␤» <-- Note the Array
Output
(Any)
{a => [1]}

Documentation, Rakudo and Raku++ all agree.

say <hello world!>.reverse;     # OUTPUT: «(world! hello)␤»
say reverse ^10;                # OUTPUT: «(9 8 7 6 5 4 3 2 1 0)␤»
Output
(world! hello)
(9 8 7 6 5 4 3 2 1 0)

Documentation, Rakudo and Raku++ all agree.

say <b c a>.sort;                           # OUTPUT: «(a b c)␤»
say 'bca'.comb.sort.join;                   # OUTPUT: «abc␤»
say 'bca'.comb.sort({$^b cmp $^a}).join;    # OUTPUT: «cba␤»
say '231'.comb.sort(&infix:«<=>»).join;     # OUTPUT: «123␤»
Output
(a b c)
abc
cba
123

Documentation, Rakudo and Raku++ all agree.

sub by-character-count { $^a.chars <=> $^b.chars }
say <Let us impart what we have seen tonight unto young Hamlet>.sort(&by-character-count);
# OUTPUT: «(us we Let what have seen unto young impart Hamlet tonight)␤»
Output
(us we Let what have seen unto young impart Hamlet tonight)

Documentation, Rakudo and Raku++ all agree.

say gather for 1 {
^3 .map: *.take;
} # OUTPUT: «(0 1 2)␤»
Output
(0 1 2)

Documentation, Rakudo and Raku++ all agree.

say [[1,2,3],[[4,5],6,7]].deepmap(* + 1);
# OUTPUT: «[[2 3 4] [[5 6] 7 8]]␤»
say deepmap * + 1, [[1,2,3],[[4,5],6,7]];
# OUTPUT: «[[2 3 4] [[5 6] 7 8]]␤»
Output
[[2 3 4] [[5 6] 7 8]]
[[2 3 4] [[5 6] 7 8]]

Documentation, Rakudo and Raku++ all agree.

{ what => "is", this => "thing", a => <real list> }.deepmap( *.flip ).say;
# OUTPUT: «{a => (laer tsil), this => gniht, what => si}␤»
say deepmap *.flip, {what=>'is', this=>'thing', a=><real list>};
# OUTPUT: «{a => (laer tsil), this => gniht, what => si}␤»
Output
{a => (laer tsil), this => gniht, what => si}
{a => (laer tsil), this => gniht, what => si}

Documentation, Rakudo and Raku++ all agree.

<a b c d e f g>.duckmap(-> $_ where <c d e>.any { .uc }).say;
# OUTPUT: «(a b C D E f g)␤»
(('d', 'e'), 'f').duckmap(-> $_ where <e f>.any { .uc }).say;
# OUTPUT: «((d E) F)␤»
{ first => ('d', 'e'), second => 'f'}.duckmap(-> $_ where <e f>.any { .uc }).say;
# OUTPUT: «{first => (d E), second => F}␤»
Output
(a b C D E f g)
((d E) F)
{first => (d E), second => F}

Documentation, Rakudo and Raku++ all agree.

say duckmap *², [[1,2,3],[[4,5],6,7]];   # OUTPUT: «[9 9]␤»
Output
[9 9]

Documentation, Rakudo and Raku++ all agree.

say duckmap -> Rat $_ { $_²}, [[1,2,3],[[4,5],6.1,7.2]];
# OUTPUT: «[[1 2 3] [[4 5] 37.21 51.84]]␤»
Output
[[1 2 3] [[4 5] 37.21 51.84]]

Documentation, Rakudo and Raku++ all agree.

say nodemap *+1, [[1,2,3], [[4,5],6,7], 7];
# OUTPUT: «(4, 4, 8)␤»
Documentation
(4, 4, 8)
Rakudo
(4 4 8)
Raku++
(4 4 8)

Both engines agree; the documentation states something else. Trust the engines.

say [[2, 3], [4, [5, 6]]]».nodemap(*+1)
# OUTPUT: «((3 4) (5 3))␤»
Output
((3 4) (5 3))

Documentation, Rakudo and Raku++ all agree.

say [[2,3], [[4,5],6,7], 7].nodemap({.elems == 1 ?? $_ !! slip});
# OUTPUT: «(() () 7)␤»
say [[2,3], [[4,5],6,7], 7].map({.elems == 1 ?? $_ !! slip});
# OUTPUT: «(7)␤»
Output
(() () 7)
(7)

Documentation, Rakudo and Raku++ all agree.

say nodemap *.flip, { what => "is", this => "thing" };
# OUTPUT: «{this => gniht, what => si}␤»
Output
{this => gniht, what => si}

Documentation, Rakudo and Raku++ all agree.

say ((1, 2), (3), %(:42a));      # OUTPUT: «((1 2) 3 {a => 42})␤»
say ((1, 2), (3), %(:42a)).flat; # OUTPUT: «(1 2 3 a => 42)␤»
Output
((1 2) 3 {a => 42})
(1 2 3 a => 42)

Documentation, Rakudo and Raku++ all agree.

say [[1, 2, 3], [(4, 5), 6, 7]]      .flat; # OUTPUT: «([1 2 3] [(4 5) 6 7])␤»
say [[1, 2, 3], [(4, 5), 6, 7]]».List.flat; # OUTPUT: «(1 2 3 4 5 6 7)␤»
Output
([1 2 3] [(4 5) 6 7])
(1 2 3 4 5 6 7)

Documentation, Rakudo and Raku++ all agree.

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

Documentation, Rakudo and Raku++ all agree.

say elems 42;                   # OUTPUT: «1␤»
say <a b c>.elems;              # OUTPUT: «3␤»
say Whatever.elems ;            # OUTPUT: «1␤»
Output
1
3
1

Documentation, Rakudo and Raku++ all agree.

say 6.end;                      # OUTPUT: «0␤»
say <a b c>.end;                # OUTPUT: «2␤»
say end ^9;                     # OUTPUT: «8␤»
Output
0
2
8

Documentation, Rakudo and Raku++ all agree.

Range.pairup.say; # OUTPUT: «()␤»
Output
()

Documentation, Rakudo and Raku++ all agree.

say (a => 1, 'b', 'c').pairup.raku;     # OUTPUT: «(:a(1), :b("c")).Seq␤»
Output
(:a(1), :b("c")).Seq

Documentation, Rakudo and Raku++ all agree.

my $b;                 # defaults to Any
say $b.serial.^name;   # OUTPUT: «Any␤»
say $b.^name;          # OUTPUT: «Any␤»
my $breakfast = 'food';
$breakfast.serial.say; # OUTPUT: «food␤»
Output
Any
Any
food

Documentation, Rakudo and Raku++ all agree.

my $d; # $d is Any
say $d.hash; # OUTPUT: {}

my %m is Map = a => 42, b => 666;
say %m.hash;  # OUTPUT: «Map.new((a => 42, b => 666))␤»
say %m.Hash;  # OUTPUT: «{a => 42, b => 666}␤»
Documentation
Map.new((a => 42, b => 666))
{a => 42, b => 666}
Rakudo
{}
Map.new((a => 42, b => 666))
{a => 42, b => 666}
Raku++
{}
{a => 42, b => 666}

All three differ. Needs a human.

Not yet examined. Which of these is correct has not been established — do not treat either engine as settled here.

say (1,7,3).min();              # OUTPUT: «1␤»
say (1,7,3).min({1/$_});        # OUTPUT: «7␤»
say min(1,7,3);                 # OUTPUT: «1␤»
say min(1,7,3,:by( { 1/$_ } )); # OUTPUT: «7␤»
min( %(a => 3, b=> 7 ) ).say ;  # OUTPUT: «a => 3␤»
Output
1
7
1
7
a => 3

Documentation, Rakudo and Raku++ all agree.

say <a b c a>.min(:k);  # OUTPUT:«(0 3)␤»
say <a b c a>.min(:v);  # OUTPUT:«(a a)␤»
say <a b c a>.min(:kv); # OUTPUT:«(0 a 3 a)␤»
say <a b c a>.min(:p);  # OUTPUT:«(0 => a 3 => a)␤»
Output
(0 3)
(a a)
(0 a 3 a)
(0 => a 3 => a)

Documentation, Rakudo and Raku++ all agree.

say (1,7,3).max();                # OUTPUT: «7␤»
say (1,7,3).max({1/$_});          # OUTPUT: «1␤»
say max(1,7,3,:by( { 1/$_ } ));   # OUTPUT: «1␤»
say max(1,7,3);                   # OUTPUT: «7␤»
max( %(a => 'B', b=> 'C' ) ).say; # OUTPUT: «b => C␤»
Output
7
1
1
7
b => C

Documentation, Rakudo and Raku++ all agree.

say <a b c c>.max(:k);  # OUTPUT:«(2 3)␤»
say <a b c c>.max(:v);  # OUTPUT:«(c c)␤»
say <a b c c>.max(:kv); # OUTPUT:«(2 c 3 c)␤»
say <a b c c>.max(:p);  # OUTPUT:«(2 => c 3 => c)␤»
Output
(2 3)
(c c)
(2 c 3 c)
(2 => c 3 => c)

Documentation, Rakudo and Raku++ all agree.

say (1,7,3).minmax();        # OUTPUT:«1..7␤»
say (1,7,3).minmax({-$_});   # OUTPUT:«7..1␤»
say minmax(1,7,3);           # OUTPUT: «1..7␤»
say minmax(1,7,3,:by( -* )); # OUTPUT: «7..1␤»
Output
1..7
7..1
1..7
7..1

Documentation, Rakudo and Raku++ all agree.

<a b c a b c>.minpairs.raku.put; # OUTPUT: «(0 => "a", 3 => "a").Seq␤»
%(:42a, :75b).minpairs.raku.put; # OUTPUT: «(:a(42),).Seq␤»
Documentation
(0 => "a", 3 => "a").Seq
(:a(42),).Seq
Rakudo
(0 => "a", 3 => "a")
(:a(42),)
Raku++
("0" => "a", "3" => "a")
(:a(42),)

All three differ. Needs a human.

Not yet examined. Which of these is correct has not been established — do not treat either engine as settled here.

<a b c a b c>.maxpairs.raku.put; # OUTPUT: «(2 => "c", 5 => "c").Seq␤»
%(:42a, :75b).maxpairs.raku.put; # OUTPUT: «(:b(75),).Seq␤»
Documentation
(2 => "c", 5 => "c").Seq
(:b(75),).Seq
Rakudo
(2 => "c", 5 => "c")
(:b(75),)
Raku++
("2" => "c", "5" => "c")
(:b(75),)

All three differ. Needs a human.

Not yet examined. Which of these is correct has not been established — do not treat either engine as settled here.

my $setty = Set(<Þor Oðin Freija>);
say $setty.keys; # OUTPUT: «(Þor Oðin Freija)␤»
Documentation
(Þor Oðin Freija)
Rakudo
(Freija Þor Oðin)
Raku++
(Freija Oðin Þor)

All three differ. Needs a human.

Not yet examined. Which of these is correct has not been established — do not treat either engine as settled here.

my Mix $m = ("þ" xx 3, "ð" xx 4, "ß" xx 5).Mix;
say $m.roll;    # OUTPUT: «ð␤»
say $m.roll(5); # OUTPUT: «(ß ß þ ß þ)␤»
Documentation
ð
(ß ß þ ß þ)
Rakudo
ß
(ð ð ð þ þ)
Raku++
þ
(ð ß ð ð ß)

All three differ. Needs a human.

Not yet examined. Which of these is correct has not been established — do not treat either engine as settled here.

.say for 3; # OUTPUT: «3␤»
Output
3

Documentation, Rakudo and Raku++ all agree.

my Range $rg = 'α'..'ω';
say $rg.pick(3); # OUTPUT: «(β α σ)␤»
Documentation
(β α σ)
Rakudo
(ν γ κ)
Raku++
(τ δ υ)

All three differ. Needs a human.

Not yet examined. Which of these is correct has not been established — do not treat either engine as settled here.

multi skip(\skipper, +values)

Not executed: the documentation states no expected output for this example.

say (1,2,3).are;        # OUTPUT: «(Int)␤»
say <a b c>.are;        # OUTPUT: «(Str)␤»
say <42 666>.are;       # OUTPUT: «(IntStr)␤»
say (42,666e0).are;     # OUTPUT: «(Real)␤»
say (42,i).are;         # OUTPUT: «(Numeric)␤»
say ("a",42,3.14).are;  # OUTPUT: «(Cool)␤»
say ().are;             # OUTPUT: «Nil␤»
Output
(Int)
(Str)
(IntStr)
(Real)
(Numeric)
(Cool)
Nil

Documentation, Rakudo and Raku++ all agree.

say 42.are;             # OUTPUT: «(Int)␤»
say Int.are;            # OUTPUT: «(Int)␤»
Output
(Int)
(Int)

Documentation, Rakudo and Raku++ all agree.

my %h = a => 42, b => "bar";
say %h.keys.are;        # OUTPUT: «(Str)␤»
say %h.values.are;      # OUTPUT: «(Cool)␤»
Output
(Str)
(Cool)

Documentation, Rakudo and Raku++ all agree.

say (1,2,3).are(Int);         # OUTPUT: «True␤»
say <a b c>.are(Str);         # OUTPUT: «True␤»
say <42 666>.are(Int);        # OUTPUT: «True␤»
say <42 666>.are(Str);        # OUTPUT: «True␤»
say (42,666e0).are(Real);     # OUTPUT: «True␤»
say (42,i).are(Numeric);      # OUTPUT: «True␤»
say ("a",42,3.14).are(Cool);  # OUTPUT: «True␤»
say ().are(Int);              # OUTPUT: «True␤»
Output
True
True
True
True
True
True
True
True

Documentation, Rakudo and Raku++ all agree.

Int.are(Str);      # OUTPUT: «Expected 'Str' but got 'Int'␤»
(1,2,3).are(Str);  # OUTPUT: «Expected 'Str' but got 'Int' in element 0␤»

Neither engine can run this in isolation — the example depends on context from the surrounding text.

my $a;
say $a.prepend; # OUTPUT: «[]␤»
say $a;         # OUTPUT: «[]␤»
my $b;
say $b.prepend(1,2,3); # OUTPUT: «[1 2 3]␤»
Output
[]
[]
[1 2 3]

Documentation, Rakudo and Raku++ all agree.

my $a;
say $a.unshift; # OUTPUT: «[]␤»
say $a;         # OUTPUT: «[]␤»
my $b;
say $b.unshift([1,2,3]); # OUTPUT: «[[1 2 3]]␤»
Output
[]
[]
[[1 2 3]]

Documentation, Rakudo and Raku++ all agree.

say (3..33).first;           # OUTPUT: «3␤»
say (3..33).first(:end);     # OUTPUT: «33␤»
say (⅓,⅔…30).first( 0xF );   # OUTPUT: «15␤»
say first 0xF, (⅓,⅔…30);     # OUTPUT: «15␤»
say (3..33).first( /\d\d/ ); # OUTPUT: «10␤»
Documentation
3
33
15
15
10
Rakudo
Raku++
3
33
15
(Any)
10

All three differ. Needs a human.

Not yet examined. Which of these is correct has not been established — do not treat either engine as settled here.

say (⅓,⅔…30).first( * %% 11, :end, :kv ); # OUTPUT: «(65 22)␤»
Output
(65 22)

Documentation, Rakudo and Raku++ all agree.

say (⅓,⅔…30).first( 3 | 33, :kv ); # OUTPUT: «(8 3)␤»
Output
(8 3)

Documentation, Rakudo and Raku++ all agree.

<1 2 2 3 3 3>.unique.say; # OUTPUT: «(1 2 3)␤»
say unique <1 2 2 3 3 3>; # OUTPUT: «(1 2 3)␤»
Output
(1 2 3)
(1 2 3)

Documentation, Rakudo and Raku++ all agree.

("1", 1, "1 ", 2).unique( as => Int, with => &[==] ).say; # OUTPUT: «(1 2)␤»
Output
(1 2)

Documentation, Rakudo and Raku++ all agree.

<1 -1 2 -2 3>.repeated(:as(&abs),:with(&[==])).say; # OUTPUT: «(-1 -2)␤»
(3+3i, 3+2i, 2+1i).repeated(as => *.re).say;        # OUTPUT: «(3+2i)␤»
Output
(-1 -2)
(3+2i)

Documentation, Rakudo and Raku++ all agree.

"aabbccddaa".comb.squish.say;             # OUTPUT: «(a b c d a)␤»
"aABbccdDaa".comb.squish( :as(&lc) ).say; # OUTPUT: «(a B c d a)␤»
(3+2i,3+3i,4+0i).squish( as => *.re, with => &[==]).put; # OUTPUT: «3+2i 4+0i␤»
Output
(a b c d a)
(a B c d a)
3+2i 4+0i

Documentation, Rakudo and Raku++ all agree.

say <a b c>.permutations;
# OUTPUT: «((a b c) (a c b) (b a c) (b c a) (c a b) (c b a))␤»
say set(1,2).permutations;
# OUTPUT: «((2 => True 1 => True) (1 => True 2 => True))␤»
Documentation
((a b c) (a c b) (b a c) (b c a) (c a b) (c b a))
((2 => True 1 => True) (1 => True 2 => True))
Rakudo
((a b c) (a c b) (b a c) (b c a) (c a b) (c b a))
((2 => True 1 => True) (1 => True 2 => True))
Raku++
((a b c) (a c b) (b a c) (b c a) (c a b) (c b a))
((1 => True 2 => True) (2 => True 1 => True))

Raku++ disagrees with both the documentation and Rakudo — a defect.

say 1.permutations; # OUTPUT: «((1))␤»
Output
((1))

Documentation, Rakudo and Raku++ all agree.

(1..3).join.say;       # OUTPUT: «123␤»
<a b c>.join("❧").put; # OUTPUT: «a❧b❧c␤»
Output
123
a❧b❧c

Documentation, Rakudo and Raku++ all agree.

say (1..13).categorize( * %% 3);
say categorize( * %% 3, 1..13)
# OUTPUT: «{False => [1 2 4 5 7 8 10 11 13], True => [3 6 9 12]}␤»
Documentation
{False => [1 2 4 5 7 8 10 11 13], True => [3 6 9 12]}
Rakudo
{False => [1 2 4 5 7 8 10 11 13], True => [3 6 9 12]}
{False => [1 2 4 5 7 8 10 11 13], True => [3 6 9 12]}
Raku++
{False => [1 2 4 5 7 8 10 11 13], True => [3 6 9 12]}
{False => [1 2 4 5 7 8 10 11 13], True => [3 6 9 12]}

Both engines agree; the documentation states something else. Trust the engines.

say categorize( * %% 3, -5..5, as => &abs )
# OUTPUT: «{False => [5 4 2 1 1 2 4 5], True => [3 0 3]}␤»
Output
{False => [5 4 2 1 1 2 4 5], True => [3 0 3]}

Documentation, Rakudo and Raku++ all agree.

my %leap-years;
my @years = (2002..2009).map( { Date.new( $_~"-01-01" ) } );
@years.categorize( *.is-leap-year , into => %leap-years );
say %leap-years
# OUTPUT:
# «{ False
# => [2002-01-01 2003-01-01 2005-01-01 2006-01-01 2007-01-01 2009-01-01],
#    True => [2004-01-01 2008-01-01]}␤»

Not executed: the documentation states no expected output for this example.

sub divisible-by( Int $n --> Array(Seq) ) {
gather {
    for <2 3 5 7> {
        take $_ if $n %% $_;
    }
}
}

say (3..13).categorize( &divisible-by );
# OUTPUT:
# «{2 => [4 6 8 10 12], 3 => [3 6 9 12], 5 => [5 10], 7 => [7]}␤»

Not executed: the documentation states no expected output for this example.

my @years = (2003..2008).map( { Date.new( $_~"-01-01" ) } );
@years.classify( *.is-leap-year , into => my %leap-years );
say %leap-years;
# OUTPUT: «{False => [2003-01-01 2005-01-01 2006-01-01 2007-01-01],
#           True => [2004-01-01 2008-01-01]}␤»

Not executed: the documentation states no expected output for this example.

say (1..4).reduce(&infix:<+>);   # OUTPUT: «10␤»
say reduce &infix:<+>, 1..4;     # OUTPUT: «10␤»
say reduce &min, 1..4;           # OUTPUT: «1␤»
Output
10
10
1

Documentation, Rakudo and Raku++ all agree.

sub hyphenate(Str \a, Str \b) { a ~ '-' ~ b }
say reduce &hyphenate, 'a'..'c'; # OUTPUT: «a-b-c␤»
Output
a-b-c

Documentation, Rakudo and Raku++ all agree.

say Range.reduce(&infix:<+>);    # OUTPUT: «Nil␤»
say Str.reduce(&infix:<~>);      # OUTPUT: «Nil␤»
Output
Nil
Nil

Documentation, Rakudo and Raku++ all agree.

<10 5 3>.reduce( &[*] ).say ; # OUTPUT: «150␤»
<10 5 3>.produce( &[*] ).say; # OUTPUT: «(10 50 150)␤»
Output
150
(10 50 150)

Documentation, Rakudo and Raku++ all agree.

say Num.pairs; # OUTPUT: «()␤»
Output
()

Documentation, Rakudo and Raku++ all agree.

<1 2 2 3 3 3>.Bag.pairs.say;# OUTPUT: «(1 => 1 3 => 3 2 => 2)␤»
Documentation
(1 => 1 3 => 3 2 => 2)
Rakudo
(2 => 2 1 => 1 3 => 3)
Raku++
(1 => 1 2 => 2 3 => 3)

All three differ. Needs a human.

Not yet examined. Which of these is correct has not been established — do not treat either engine as settled here.

Range.antipairs.say; # OUTPUT: «()␤»
Output
()

Documentation, Rakudo and Raku++ all agree.

%(s => 1, t=> 2, u => 3).antipairs.say ;# OUTPUT: «(2 => t 1 => s 3 => u)␤»
Documentation
(2 => t 1 => s 3 => u)
Rakudo
(2 => t 1 => s 3 => u)
Raku++
(1 => s 2 => t 3 => u)

Raku++ disagrees with both the documentation and Rakudo — a defect.

"aaabbcccc".comb.Bag.invert.say; # OUTPUT: «(4 => c 3 => a 2 => b)␤»
Documentation
(4 => c 3 => a 2 => b)
Rakudo
(2 => b 3 => a 4 => c)
Raku++
(3 => a 2 => b 4 => c)

All three differ. Needs a human.

Not yet examined. Which of these is correct has not been established — do not treat either engine as settled here.

Sub.kv.say ;# OUTPUT: «()␤»
Output
()

Documentation, Rakudo and Raku++ all agree.

<1 2 3>.kv.say; # OUTPUT: «(0 1 1 2 2 3)␤»
Output
(0 1 1 2 2 3)

Documentation, Rakudo and Raku++ all agree.

say (1..15).toggle(* < 5, * > 10, * < 15); # OUTPUT: «(1 2 3 4 11 12 13 14)␤»
say (1..15).toggle(:off, * > 2, * < 5, * > 10, * < 15); # OUTPUT: «(3 4 11 12 13 14)␤»
Output
(1 2 3 4 11 12 13 14)
(3 4 11 12 13 14)

Documentation, Rakudo and Raku++ all agree.

# our original sequence of elements:
say list ^10; # OUTPUT: «(0 1 2 3 4 5 6 7 8 9)␤»
# toggled result:
say ^10 .toggle: * < 4, * %% 2, &is-prime; # OUTPUT: «(0 1 2 3 6 7)␤»

# First tester Callable is `* < 4` and initial state of switch is "on".
# As we iterate over our original sequence:
# 0 => 0 < 4 === True  switch is on, value gets into result, switch is
#                      toggled, so we keep using the same Callable:
# 1 => 1 < 4 === True  same
# 2 => 2 < 4 === True  same
# 3 => 3 < 4 === True  same
# 4 => 4 < 4 === False switch is now off, "4" does not make it into the
#                      result. In addition, our switch got toggled, so
#                      we're switching to the next tester Callable
# 5 => 5 %% 2 === False  switch is still off, keep trying to find a value
# 6 => 6 %% 2 === True   switch is now on, take "6" into result. The switch
#                        toggled, so we'll use the next tester Callable
# 7 => is-prime(7) === True  switch is still on, take value and keep going
# 8 => is-prime(8) === False switch is now off, "8" does not make it into
#                            the result. The switch got toggled, but we
#                            don't have any more tester Callables, so it
#                            will remain off for the rest of the sequence.
Output
(0 1 2 3 4 5 6 7 8 9)
(0 1 2 3 6 7)

Documentation, Rakudo and Raku++ all agree.

# our original sequence of elements:
say <0 1 2>; # OUTPUT: «(0 1 2)␤»
# toggled result:
say <0 1 2>.toggle: * > 1; # OUTPUT: «()␤»

# First tester Callable is `* > 1` and initial state of switch is "on".
# As we iterate over our original sequence:
# 0 => 0 > 1 === False  switch is off, "0" does not make it into result.
#                      In addition, switch got toggled, so we change the
#                      tester Callable, and since we don't have any more
#                      of them, the switch will remain "off" until the end
Output
(0 1 2)
()

Documentation, Rakudo and Raku++ all agree.

# our original sequence of elements:
say <0 1 2>; # OUTPUT: «(0 1 2)␤»
# toggled result:
say <0 1 2>.toggle: :off, * > 1; # OUTPUT: «(2)␤»

# First tester Callable is `* > 1` and initial state of switch is "off".
# As we iterate over our original sequence:
# 0 => 0 > 1 === False  switch is off, "0" does not make it into result.
#                       The switch did NOT get toggled this time, so we
#                       keep using our current tester Callable
# 1 => 1 > 1 === False  same
# 2 => 2 > 1 === True   switch is on, "2" makes it into the result
Output
(0 1 2)
(2)

Documentation, Rakudo and Raku++ all agree.

"aaabbc".comb.head.put; # OUTPUT: «a␤»
say ^10 .head(5);           # OUTPUT: «(0 1 2 3 4)␤»
say ^∞ .head(5);            # OUTPUT: «(0 1 2 3 4)␤»
say ^10 .head;              # OUTPUT: «0␤»
say ^∞ .head;               # OUTPUT: «0␤»
Output
a
(0 1 2 3 4)
(0 1 2 3 4)
0
0

Documentation, Rakudo and Raku++ all agree.

say (^10).head( * - 3 );# OUTPUT: «(0 1 2 3 4 5 6)␤»
Output
(0 1 2 3 4 5 6)

Documentation, Rakudo and Raku++ all agree.

multi head(\specifier, +values)

Not executed: the documentation states no expected output for this example.

say (^12).reverse.tail ;     # OUTPUT: «0␤»
say (^12).reverse.tail(3);   # OUTPUT: «(2 1 0)␤»
say (^12).reverse.tail(*-7); # OUTPUT: «(4 3 2 1 0)␤»
Output
0
(2 1 0)
(4 3 2 1 0)

Documentation, Rakudo and Raku++ all agree.

multi tail(\specifier, +values)

Not executed: the documentation states no expected output for this example.

say Any.tree; # OUTPUT: «Any␤»
Documentation
Any
Rakudo
(Any)
Raku++
(Any)

Both engines agree; the documentation states something else. Trust the engines.

my @floors = ( 'A', ('B','C', ('E','F','G')));
say @floors.tree(1).flat.elems; # OUTPUT: «6␤»
say @floors.tree(2).flat.elems; # OUTPUT: «2␤»
say @floors.tree( *.join("-"),*.join("—"),*.join("|"));# OUTPUT: «A-B—C—E|F|G␤»
Output
6
2
A-B—C—E|F|G

Documentation, Rakudo and Raku++ all agree.

Num.nl-out.print;     # OUTPUT: «␤»
Whatever.nl-out.print;# OUTPUT: «␤»
33.nl-out.print;      # OUTPUT: «␤»
Output



Documentation, Rakudo and Raku++ all agree.

say (^3).combinations; # OUTPUT: «(() (0) (1) (2) (0 1) (0 2) (1 2) (0 1 2))␤»
Output
(() (0) (1) (2) (0 1) (0 2) (1 2) (0 1 2))

Documentation, Rakudo and Raku++ all agree.

say set().combinations; # OUTPUT: «(())␤»
Output
(())

Documentation, Rakudo and Raku++ all agree.

my $a;
say $a.grep({ True }); # OUTPUT: «((Any))␤»
say $a.grep({ $_ });   # OUTPUT: «()␤»
Documentation
((Any))
()
Rakudo
((Any))
()
Raku++
()
()

Raku++ disagrees with both the documentation and Rakudo — a defect.

my $a;
say $a.append; # OUTPUT: «[]␤»
my $b;
say $b.append((1,2,3)); # OUTPUT: «[1 2 3]␤»
Output
[]
[1 2 3]

Documentation, Rakudo and Raku++ all agree.

say (1..3).values; # OUTPUT: «(1 2 3)␤»
say List.values;   # OUTPUT: «()␤»
Output
(1 2 3)
()

Documentation, Rakudo and Raku++ all agree.

say ('a', 'Z').sort; # (Z a)
say ('a', 'Z').collate; # (a Z)
say <ä a o ö>.collate; # (a ä o ö)
my %hash = 'aa' => 'value', 'Za' => 'second';
say %hash.collate; # (aa => value Za => second);

Not executed: the documentation states no expected output for this example.

$*COLLATION.set(:quaternary(False), :tertiary(False));
say 'a' coll 'A'; # OUTPUT: «Same␤»
say ('a','A').collate == ('A','a').collate; # OUTPUT: «True␤»
Documentation
Same
True
Rakudo
Same
True
Raku++

Raku++ disagrees with both the documentation and Rakudo — a defect.

say (3..9).rotor(3); # OUTPUT: «((3 4 5) (6 7 8))␤»
Output
((3 4 5) (6 7 8))

Documentation, Rakudo and Raku++ all agree.

say (3..10).rotor(3, :partial); # OUTPUT: «((3 4 5) (6 7 8) (9 10))␤»
Output
((3 4 5) (6 7 8) (9 10))

Documentation, Rakudo and Raku++ all agree.

say (3..11).rotor(3, 2 => 1, 3 => -2, :partial);
# OUTPUT: «((3 4 5) (6 7) (9 10 11) (10 11))␤»
Output
((3 4 5) (6 7) (9 10 11) (10 11))

Documentation, Rakudo and Raku++ all agree.

say (3..11).rotor(3, 2 => 1, 3 => -4, :partial);
# OUTPUT: «(exit code 1) Rotorizing gap is out of range. Is: -4, should be in
# -3..^Inf; ␤Ensure a negative gap is not larger than the length of the
# sublist␤ ␤␤»

Not executed: the documentation states no expected output for this example.

say (3..9).rotor(3+⅓); # OUTPUT: «((3 4 5) (6 7 8))␤»
Output
((3 4 5) (6 7 8))

Documentation, Rakudo and Raku++ all agree.

(3,2,1).sum; # OUTPUT: «6␤»
say 3.sum;   # OUTPUT: «3␤»
Documentation
6
3
Rakudo
3
Raku++
3

Both engines agree; the documentation states something else. Trust the engines.

say (1..10).slice(0, 3..6, 8);  # OUTPUT: «(1 4 5 6 7 9)␤»
Output
(1 4 5 6 7 9)

Documentation, Rakudo and Raku++ all agree.

.say for snip * < 10, 2, 5, 13, 9, 6;      # OUTPUT: «(2 5)␤(13 9 6)␤»
.say for snip (* < 10, * < 20), 5, 13, 29; # OUTPUT: «(5)␤(13)␤(29)␤»
.say for snip Int, 2, 5, 5, "a", "b";      # OUTPUT: «(2 5 5)␤(a b)␤»
.say for (2, 5, 13, 9, 6).snip(* < 10);    # OUTPUT: «(2 5)␤(13 9 6)␤»
.say for (5, 13,29).snip(* < 10, * < 20);  # OUTPUT: «(5)␤(13)␤(29)␤»
.say for (2, 5, 5, "a", "b").snip: Int;    # OUTPUT: «(2 5 5)␤(a b)␤»
Documentation
(2 5)
(13 9 6)
(5)
(13)
(29)
(2 5 5)
(a b)
(2 5)
(13 9 6)
(5)
(13)
(29)
(2 5 5)
(a b)
Rakudo
(2 5)
(13 9 6)
(5)
(13)
(29)
(2 5 5)
(a b)
(2 5)
(13 9 6)
(5)
(13)
(29)
(2 5 5)
(a b)
Raku++
0

Raku++ disagrees with both the documentation and Rakudo — a defect.

(my $a = 42).snitch = 666; say $a;  # OUTPUT: «42␤666␤»
(1..5).snitch;                      # OUTPUT: «1..5␤»
(1..5).Seq.snitch;                  # OUTPUT: «(1 2 3 4 5)␤»
(1..5).Seq.snitch(&dd);             # OUTPUT: «(1, 2, 3, 4, 5).Seq␤»
(1..5).map(*+1).snitch;             # OUTPUT: «(2 3 4 5 6)␤»
say (1..3).Seq.snitch.map(*+2);     # OUTPUT: «(1 2 3)␤(3 4 5)␤»
Documentation
42
666
1..5
(1 2 3 4 5)
(1, 2, 3, 4, 5).Seq
(2 3 4 5 6)
(1 2 3)
(3 4 5)
Rakudo
666
(3 4 5)
Raku++

All three differ. Needs a human.

Not yet examined. Which of these is correct has not been established — do not treat either engine as settled here.

(1..3).Seq ==> snitch() ==> map(*+2) ==> say();  # OUTPUT: «(1 2 3)␤(3 4 5)␤»
Documentation
(1 2 3)
(3 4 5)
Rakudo
(3 4 5)
Raku++

All three differ. Needs a human.

Not yet examined. Which of these is correct has not been established — do not treat either engine as settled here.

my @snitched;
my @result = (1..3).Seq.snitch({ @snitched.push($_) }).map(*+2);
say @snitched;  # OUTPUT: «[(1 2 3)]␤»
say @result;    # OUTPUT: «[3 4 5]␤»
Documentation
[(1 2 3)]
[3 4 5]
Rakudo
Raku++
[(1 2 3)]
[3 4 5]

Raku++ matches the documentation; Rakudo does not. This is the one class where neither engine can be assumed right: it may be a stale doc that Raku++ was built from, or it may be a Rakudo bug that the documentation predates. Each case is examined individually.

Not yet examined. Which of these is correct has not been established — do not treat either engine as settled here.