enum Bool

Logical boolean

An enum for boolean true/false decisions.

Methods

routine succ

Returns `True`.

`succ` is short for "successor"; it returns the next enum value. Bool is a special enum with only two values, `False` and `True`. When sorted, `False` comes first, so `True` is its successor. And since `True` is the "highest" Bool enum value, its own successor is also `True`.

routine pred

Returns `False`.

`pred` is short for "predecessor"; it returns the previous enum value. Bool is a special enum with only two values, `False` and `True`. When sorted, `False` comes first, so `False` is the predecessor to `True`. And since `False` is the "lowest" Bool enum value, its own predecessor is also `False`.

routine enums

Returns a Hash of enum-pairs. Works on both the `Bool` type and any key.

routine pick

Returns `True` or `False` if called without any argument. Otherwise returns `\$count` elements chosen at random (without repetition) from the `enum`. If `*` is passed as `\$count`, or `\$count` is greater than or equal to two, then both elements are returned in random order.

routine roll

Returns `True` or `False` if called without any argument. Otherwise returns `\$count` elements chosen at random. Note that each random choice from the `enum` is made independently, like a separate coin toss where each side of the coin represents one of the two values of the `enum`. If `*` is passed as `\$count` an infinite Seq of `Bool`s is returned.

routine Numeric

Returns the value part of the `enum` pair.

Operators

prefix ?

Coerces its argument to `Bool`.

prefix so

Coerces its argument to `Bool`, has looser precedence than `prefix:<?> `.

Routines supplied by class Int

Bool inherits from class Int, which provides the following methods:

(Int) method Capture

Defined as:

Throws `X::Cannot::Capture`.

(Int) routine chr

Defined as:

Returns a one-character string, by interpreting the integer as a Unicode codepoint number and converting it to the corresponding character.

Example:

(Int) routine expmod

Defined as:

Returns the given `Int` raised to the `\$y` power within modulus `\$mod`, that is gives the result of `(\$x ** \$y) mod \$mod`. The subroutine form can accept non-`Int` arguments, which will be coerced to `Int`.

(Int) method polymod

Defined as:

Returns a sequence of mod results corresponding to the divisors in `@mods`. The divisors are given from smallest "unit" to the largest (e.g. 60 seconds per minute, 60 minutes per hour) and the results are returned in the same way: from smallest to the largest (5 seconds, 4 minutes).

Returns one more item in the result than the number of given divisors. If the divisors are given as a lazy list, runs until the remainder is 0 or the list of divisors is exhausted. All divisors must be `Int`s, unless the method is called on a non-`Int` number.

To illustrate how the `Int`, non-lazy version of polymod works, consider this code that implements it:

For a more detailed discussion, see this blog post

(Int) routine is-prime

Defined as:

Returns `True` if this `Int` is known to be a prime, or is likely to be a prime based on a probabilistic Miller-Rabin test.

Returns `False` if this `Int` is known not to be a prime.

(Int) routine lsb

Defined as:

Returns Nil if the number is 0. Otherwise returns the zero-based index from the right of the least significant (rightmost) 1 in the binary representation of the number.

(Int) routine msb

Defined as:

Returns Nil if the number is 0. Otherwise returns the zero-based index from the right of the most significant (leftmost) 1 in the binary representation of the number.

(Int) routine unival

Defined as:

Returns the number represented by the Unicode codepoint with the given integer number, or NaN if it does not represent a number.

(Int) infix div

Does an integer division, rounded down.

Methods supplied by role Real

Bool inherits from class Int, which does role Real, which provides the following methods:

(Real) method Bridge

Defined as:

Default implementation coerces the invocant to Num and that's the behaviour of this method in core Real types. This method primarily exist to make it easy to implement custom Real types by users, with the `Bridge` method returning one of the core `Real` types (NOT necessarily a Num) that best represent the custom `Real` type. In turn, this lets all the core operators and methods obtain a usable value they can work with.

As an example, we can implement a custom `Temperature` type. It has a unit of measure and the value, which are given during instantiation. We can implement custom operators or conversion methods that work with this type. When it comes to regular mathematical operators, however, we can simply use the `.Bridge` method to convert the `Temperature` to Kelvin expressed in one of the core numeric types:

As we can see from the last two lines of the output, the type of the bridged result is not forced to be any particular core type. It is a Rat, when we instantiated `Temperature` with a `Rat` or when conversion was involved, and it is an Int when we instantiated `Temperature` with an Int.

(Real) method Rat

Converts the number to a `Rat` with the precision `\$epsilon`.

(Real) method Real

Defined as:

The `:D` variant simply returns the invocant. The `:U` variant issues a warning about using an uninitialized value in numeric context and then returns `self.new`.

(Real) routine rand

Returns a pseudo-random number between zero (inclusive) and the number (non-inclusive.)

The term form returns a pseudo-random `Num` between 0e0 (inclusive) and 1e0 (non-inclusive.)

(Real) method sign

Returns `-1` if the number is negative, `0` if it is zero and `1` otherwise.

(Real) method round

Rounds the number to scale `\$scale`. If `\$scale` is 1, rounds to an integer. If scale is `0.1`, rounds to one digit after the comma etc.

(Real) method floor

Return the largest integer not greater than the number.

(Real) method ceiling

Returns the smallest integer not less than the number.

(Real) method truncate

Rounds the number towards zero.

(Real) method base

Converts the number to a string, using `\$base` as base. For `\$base` larger than ten, capital Latin letters are used.

The optional `\$digits` argument asks for that many digits of fraction (which may not be negative). If omitted, a reasonable default is chosen based on type. For Int this default is 0. For Num, the default is 8. For Rational, the number of places is scaled to the size of the denominator, with a minimum of 6.

A special value of `Whatever` (`*`) can be given as `\$digits`, which functions the same as when `\$digits` is not specified for all `Real` types except the `Rationals`. For `Rationals`, the `Whatever` indicates that you wish all of the possible digits of the fractional part, but use caution: since there's no detection of repeating fractional parts (the algorithm will eventually stop after generating 2**63 digits).

The final digit produced is always rounded.

For reverse operation, see `parse-base`

Routines supplied by class Cool

Bool inherits from class Cool, which provides the following methods:

(Cool) routine abs

Defined as:

Coerces the invocant (or in the sub form, the argument) to Numeric and returns the absolute value (that is, a non-negative number).

(Cool) method conj

Defined as:

Coerces the invocant to Numeric and returns the complex conjugate (that is, the number with the sign of the imaginary part negated).

(Cool) routine sqrt

Defined as:

Coerces the invocant to Numeric (or in the sub form, the argument) and returns the square root, that is, a non-negative number that, when multiplied with itself, produces the original number.

(Cool) method sign

Defined as:

Coerces the invocant to Numeric and returns its sign, that is, 0 if the number is 0, 1 for positive and -1 for negative values.

(Cool) method rand

Defined as:

Coerces the invocant to Num and returns a pseudo-random value between zero and the number.

(Cool) routine sin

Defined as:

Coerces the invocant (or in the sub form, the argument) to Numeric, interprets it as radians, returns its sine.

Note that Perl 6 is no computer algebra system, so `sin(pi)` typically does not produce an exact 0, but rather a very small floating-point number.

(Cool) routine asin

Defined as:

Coerces the invocant (or in the sub form, the argument) to Numeric, and returns its arc-sine in radians.

(Cool) routine cos

Defined as:

Coerces the invocant (or in sub form, the argument) to Numeric, interprets it as radians, returns its cosine.

(Cool) routine acos

Defined as:

Coerces the invocant (or in sub form, the argument) to Numeric, and returns its arc-cosine in radians.

(Cool) routine tan

Defined as:

Coerces the invocant (or in sub form, the argument) to Numeric, interprets it as radians, returns its tangent.

(Cool) routine atan

Defined as:

Coerces the invocant (or in sub form, the argument) to Numeric, and returns its arc-tangent in radians.

(Cool) routine atan2

Defined as:

Coerces the arguments (including the invocant in the method form) to Numeric, and returns their two-argument arc-tangent in radians.

(Cool) method sec

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, interprets it as radians, returns its secant, that is, the reciprocal of its cosine.

(Cool) routine asec

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and returns its arc-secant in radians.

(Cool) routine cosec

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, interprets it as radians, returns its cosecant, that is, the reciprocal of its sine.

(Cool) routine acosec

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and returns its arc-cosecant in radians.

(Cool) routine cotan

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, interprets it as radians, returns its cotangent, that is, the reciprocal of its tangent.

(Cool) routine acotan

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and returns its arc-cotangent in radians.

(Cool) routine sinh

Defined as:

Coerces the invocant (or in method form, its argument) to Numeric, and returns its Sine hyperbolicus.

(Cool) routine asinh

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and returns its Inverse Sine hyperbolicus.

(Cool) routine cosh

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and returns its Cosine hyperbolicus.

(Cool) routine acosh

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and returns its Inverse Cosine hyperbolicus.

(Cool) routine tanh

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, interprets it as radians and returns its Tangent hyperbolicus.

(Cool) routine atanh

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and returns its Inverse tangent hyperbolicus.

(Cool) routine sech

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and returns its Secant hyperbolicus.

(Cool) routine asech

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and returns its Inverse hyperbolic secant.

(Cool) routine cosech

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and returns its Hyperbolic cosecant.

(Cool) routine acosech

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and returns its Inverse hyperbolic cosecant.

(Cool) routine cotanh

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and returns its Hyperbolic cotangent.

(Cool) routine acotanh

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and returns its Inverse hyperbolic cotangent.

(Cool) routine cis

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and returns cos(argument) + i*sin(argument).

(Cool) routine log

Defined as:

Coerces the arguments (including the invocant in the method form) to Numeric, and returns its Logarithm to base `\$base`, or to base `e` (Euler's Number) if no base was supplied (Natural logarithm). Returns `NaN` if `\$base` is negative. Throws an exception if `\$base` is `1`.

(Cool) routine log10

Defined as:

Coerces the invocant (or in the sub form, the invocant) to Numeric, and returns its Logarithm to base 10, that is, a number that approximately produces the original number when raised to the power of 10. Returns `NaN` for negative arguments and `-Inf` for `0`.

(Cool) method exp

Defined as:

Coerces the arguments (including the invocant in the method from) to Numeric, and returns `\$base` raised to the power of the first number. If no `\$base` is supplied, `e` (Euler's Number) is used.

(Cool) method unpolar

Defined as:

Coerces the arguments (including the invocant in the method form) to Numeric, and returns a complex number from the given polar coordinates. The invocant (or the first argument in sub form) is the magnitude while the argument (i.e. the second argument in sub form) is the angle. The angle is assumed to be in radians.

(Cool) routine round

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and rounds it to the unit of `\$unit`. If `\$unit` is 1, rounds to the nearest integer.

Always rounds up if the number is at mid-point:

(Cool) routine floor

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and rounds it downwards to the nearest integer.

(Cool) routine ceiling

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and rounds it upwards to the nearest integer.

(Cool) routine truncate

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and rounds it towards zero.

(Cool) routine ord

Defined as:

Coerces the invocant (or in sub form, its argument) to Str, and returns the Unicode code point number of the first code point.

The inverse operation is chr.

Mnemonic: returns an ordinal number

(Cool) method path

Defined as:

DEPRECATED. Existed only in the Rakudo implementation and isn't part of any language released. Issues deprecation warnings in 6.d language and will be removed entirely when 6.e language is released.

Stringifies the invocant and converts it to IO::Path object. Use the `.IO method` instead.

(Cool) routine chr

Defined as:

Coerces the invocant (or in sub form, its argument) to Int, interprets it as a Unicode code points, and returns a string made of that code point.

The inverse operation is ord.

Mnemonic: turns an integer into a character.

(Cool) routine chars

Defined as:

Coerces the invocant (or in sub form, its argument) to Str, and returns the number of characters in the string. Please note that on the JVM, you currently get codepoints instead of graphemes.

Graphemes are user visible characters. That is, this is what the user thinks of as a “character”.

Graphemes can contain more than one codepoint. Typically the number of graphemes and codepoints differs when `Prepend` or `Extend` characters are involved (also known as Combining characters), but there are many other cases when this may happen. Another example is `\c[ZWJ]` (Zero-width joiner).

You can check `Grapheme_Cluster_Break` property of a character in order to see how it is going to behave:

You can read more about graphemes in the Unicode Standard, which Perl 6 tightly follows.

(Cool) routine codes

Defined as:

Coerces the invocant (or in sub form, its argument) to Str, and returns the number of Unicode code points.

The same result will be obtained with

ords first obtains the actual codepoints, so there might be a difference in speed.

(Cool) routine flip

Defined as:

Coerces the invocant (or in sub form, its argument) to Str, and returns a reversed version.

(Cool) routine trim

Defined as:

Coerces the invocant (or in sub form, its argument) to Str, and returns the string with both leading and trailing whitespace stripped.

Defined as:

Coerces the invocant (or in sub form, its argument) to Str, and returns the string with leading whitespace stripped.

(Cool) routine trim-trailing

Defined as:

Coerces the invocant (or in sub form, its argument) to Str, and returns the string with trailing whitespace stripped.

(Cool) routine lc

Defined as:

Coerces the invocant (or in sub form, its argument) to Str, and returns it case-folded to lower case.

(Cool) routine uc

Defined as:

Coerces the invocant (or in sub form, its argument) to Str, and returns it case-folded to upper case (capital letters).

(Cool) routine fc

Defined as:

Coerces the invocant (or in sub form, its argument) to Str, and returns the result a Unicode "case fold" operation suitable for doing caseless string comparisons. (In general, the returned string is unlikely to be useful for any purpose other than comparison.)

(Cool) routine tc

Defined as:

Coerces the invocant (or in sub form, its argument) to Str, and returns it with the first letter case-folded to title case (or where not available, upper case).

(Cool) routine tclc

Defined as:

Coerces the invocant (or in sub form, its argument) to Str, and returns it with the first letter case-folded to title case (or where not available, upper case), and the rest of the string case-folded to lower case.

(Cool) routine wordcase

Defined as:

Coerces the invocant (or in sub form, the first argument) to Str, and filters each word that smart-matches against `\$where` through the `&filter`. With the default filter (first character to upper case, rest to lower) and matcher (which accepts everything), this title-cases each word:

With a matcher:

With a customer filter too:

(Cool) routine samecase

Defined as:

Coerces the invocant (or in sub form, the first argument) to Str, and returns a copy of `\$string` with case information for each individual character changed according to `\$pattern`. (The pattern string can contain three types of characters, i.e. uppercase, lowercase and caseless. For a given character in `\$pattern` its case information determines the case of the corresponding character in the result.) If `\$string` is longer than `\$pattern`, the case information from the last character of `\$pattern` is applied to the remaining characters of `\$string`.

(Cool) method uniprop

Defined as:

Interprets the invocant as a Str, and returns the unicode property of the first character. If no property is specified returns the General Category. Returns a Bool for Boolean properties.

(Cool) method uniprops

Defined as:

Interprets the invocant as a Str, and returns the unicode property for each character as a Seq. If no property is specified returns the General Category. Returns a Bool for Boolean properties. Similar to uniprop

(Cool) method uniname

Defined as:

Interprets the invocant / first argument as a Str, and returns the Unicode codepoint name of the first codepoint of the first character. See uninames for a routine that works with multiple codepoints, and uniparse for the opposite direction.

(Cool) method uninames

Defined as:

Returns of a Seq of Unicode names for the all the codepoints in the Str provided.

Note this example, which gets a Seq where each element is a Seq of all the codepoints in that character.

See uniparse for the opposite direction.

(Cool) method unimatch

Defined as:

Checks if the given integer codepoint or the first letter of the string given have a unicode property equal to the value you give. If you supply the Unicode property to be checked it will only return True if that property matches the given value.

(Cool) routine chop

Defined as:

Coerces the invocant (or in sub form, its argument) to Str, and returns it with the last character removed.

(Cool) routine chomp

Defined as:

Coerces the invocant (or in sub form, its argument) to Str, and returns it with the last character removed, if it is a logical newline.

(Cool) routine substr

Defined as:

Coerces the invocant (or in the sub form, the first argument) to Str, and calls Str.substr with the arguments.

(Cool) routine ords

Defined as:

Coerces the invocant (or in the sub form, the first argument) to Str, and returns a list of Unicode codepoints for each character.

This is the list-returning version of ord. The inverse operation in chrs. If you are only interested in the number of codepoints, codes is a possibly faster option.

(Cool) routine chrs

Defined as:

Coerces the invocant (or in the sub form, the argument list) to a list of integers, and returns the string created by interpreting each integer as a Unicode codepoint, and joining the characters.

This is the list-input version of chr. The inverse operation is ords.

(Cool) routine split

Defined as:

Coerces the invocant (or in the sub form, the second argument) to Str, and splits it into pieces based on delimiters found in the string.

If `\$delimiter` is a string, it is searched for literally and not treated as a regex. You can also provide multiple delimiters by specifying them as a list; mixing Cool and Regex objects is OK.

By default, split omits the matches, and returns a list of only those parts of the string that did not match. Specifying one of the `:k, :v, :kv, :p` adverbs changes that. Think of the matches as a list that is interleaved with the non-matching parts.

The `:v` interleaves the values of that list, which will be either Match objects, if a Regex was used as a matcher in the split, or Str objects, if a Cool was used as matcher. If multiple delimiters are specified, Match objects will be generated for all of them, unless all of the delimiters are Cool.

`:k` interleaves the keys, that is, the indexes:

`:kv` adds both indexes and matches:

and `:p` adds them as Pairs, using the same types for values as `:v` does:

You can only use one of the `:k, :v, :kv, :p` adverbs in a single call to `split`.

Note that empty chunks are not removed from the result list. For that behavior, use the `:skip-empty` named argument:

(Cool) routine lines

Defined as:

Coerces the invocant (and in sub form, the argument) to Str, decomposes it into lines (with the newline characters stripped), and returns the list of lines.

This method can be used as part of an `IO::Path` to process a file line-by-line, since `IO::Path` objects inherit from `Cool`, e.g.:

Without any arguments, sub `lines` operates on `\$*ARGFILES`, which defaults to `\$*IN` in the absence of any filenames.

To modify values in place use `is copy` to force a writable container.

(Cool) method words

Defined as:

Coerces the invocant to Str, and returns a list of words that make up the string (and if `\$limit` is supplied, only the first `\$limit` words).

Only whitespace counts as word boundaries

(Cool) routine comb

Defined as:

Returns all (or if supplied, at most `\$limit`) matches of the invocant (method form) or the second argument (sub form) against the Regex as a list of strings.

(Cool) method contains

Coerces the invocant and first argument to Str, and searches for `\$needle` in the string starting from `\$start`. Returns `True` if `\$needle` is found.

Note that because of how a List or Array is coerced into a Str, the results may sometimes be surprising. See traps.

(Cool) routine index

Defined as:

Coerces the first two arguments (in method form, also counting the invocant) to Str, and searches for `\$needle` in the string starting from `\$startpos`. It returns the offset into the string where `\$needle` was found, and an undefined value if it was not found.

See the documentation in type Str for examples.

(Cool) routine rindex

Defined as:

Coerces the first two arguments (including the invocant in method form) to Str and `\$startpos` to Int, and returns the last position of `\$needle` in `\$haystack` not after `\$startpos`. Returns an undefined value if `\$needle` wasn't found.

See the documentation in type Str for examples.

(Cool) routine match

Defined as:

Coerces the invocant to Str and calls the method match on it.

(Cool) method fmt

Defined as:

Uses `\$format` to return a formatted representation of the invocant.

(Cool) routine roots

Defined as:

Coerces the first argument (and in method form, the invocant) to Numeric and the second (`\$n`) to Int, and produces a list of `\$n` Complex `\$n`-roots, which means numbers that, raised to the `\$n`th power, approximately produce the original number.

For example

(Cool) method IO

Defined as:

Coerces the invocant to IO::Path.

(Cool) routine EVAL

Defined as:

Method form calls subroutine form with invocant as `\$code`, passing along named args, if any. Subroutine form coerces Cool `\$code` to Str. If `\$code` is a Blob, it'll be processed using the same encoding as the `\$lang` compiler would: for `perl6`, uses the encoding specified via `--encoding` command line argument, or `utf-8` if none were given; for `Perl5`, processes using same rules as `perl`.

This works as-is with a literal string parameter. More complex input, such as a variable or string with embedded code, is illegal by default. This can be overridden in any of several ways:

Symbols in the current lexical scope are visible to code in an `EVAL`.

However, since the set of symbols in a lexical scope is immutable after compile time, an EVAL can never introduce symbols into the surrounding scope.

Furthermore, the `EVAL` is evaluated in the current package:

And also the current language, meaning any added syntax is available:

An `EVAL` statement evaluates to the result of the last statement:

`EVAL` is also a gateway for executing code in other languages:

(Cool) routine EVALFILE

Defined as:

Slurps the specified file and evaluates it. Behaves the same way as `EVAL` with regard to Blob decoding, scoping, and the `\$lang` parameter. Evaluates to the value produced by the final statement in the file.

Routines supplied by class Any

Bool inherits from class Any, which provides the following methods:

(Any) method ACCEPTS

Defined as:

Usage:

Returns `True` if `\$other === self` (i.e. it checks object identity).

Many built-in types override this for more specific comparisons

(Any) method any

Defined as:

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

(Any) method all

Defined as:

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

(Any) method one

Defined as:

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

(Any) method none

Defined as:

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

(Any) method list

Defined as:

Applies the infix `,` operator to the invocant and returns the resulting List:

(Any) method push

Defined as:

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.

(Any) routine reverse

Defined as:

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:

(Any) method sort

Defined as:

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:

(Any) method map

Defined as:

`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 `:\$label` and `:\$item` are useful only internally, since `for` loops get converted to `map`s. The `:\$label` takes an existing Label to label the `.map`'s loop with and `:\$item` controls whether the iteration will occur over `(SELF,)` (if `:\$item` is set) or `SELF`.

(Any) method deepmap

Defined as:

`deepmap` will apply `&block` to each element and return a new List with the return values of `&block`, unless the element does the Iterable role. For those elements deepmap will descend recursively into the sublist.

(Any) method duckmap

Defined as:

`duckmap` will apply `&block` on each element and return a new list with defined return values of the block. For undefined return values, duckmap will try to descend into the element if that element implements Iterable.

(Any) method nodemap

Defined as:

`nodemap` will apply `&block` to each element and return a new List with the return values of `&block`. In contrast to deepmap it will not descend recursively into sublists if it finds elements which does the Iterable role.

The examples above would have produced the exact same results if we had used map instead of `nodemap`. The difference between the two lies in the fact that map flattens out slips while `nodemap` doesn't.

(Any) method flat

Defined as:

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 hyper method call to call `.List` method on all the inner Iterables and so de-containerize them, so that `flat` can flatten them:

For more fine-tuned options, see deepmap, duckmap, and signature destructuring

(Any) method eager

Defined as:

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

(Any) method elems

Defined as:

Interprets the invocant as a list, and returns the number of elements in the list.

(Any) method end

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

(Any) method pairup

Defined as:

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, is considered to be a key again).

(Any) sub exit

Defined as:

Exits the current process with return code `\$status` or zero if no value has been specified. The exit value (`\$status`), when different from zero, has to be opportunely evaluated from the process that catches it (e.g., a shell).

`exit` does prevent the LEAVE phaser to be executed.

`exit` should be used as last resort only to signal the parent process about an exit code different from zero, and should not be used to terminate exceptionally a method or a sub: use exceptions instead.

It is worth noting that the only way to return an exit code different from zero from a Main function is by means of using `exit`.

(Any) sub item

Defined as:

Forces given object to be evaluated in item context and returns the value of it.

You can also use `\$` as item contextualizer.

(Any) method Array

Defined as:

Coerce the invocant to Array.

(Any) method List

Defined as:

Coerce the invocant to List, using the list method.

(Any) method Hash

Defined as:

Coerce the invocant to Hash by invoking the method `hash` on it.

(Any) method hash

Defined as:

Creates a new Hash, empty in the case the invocant is undefined, or coerces the invocant to an `Hash` in the case it is defined.

(Any) method Slip

Defined as:

Coerce the invocant to Slip.

(Any) method Map

Defined as:

Coerce the invocant to Map.

(Any) method Bag

Defined as:

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

(Any) method BagHash

Defined as:

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

(Any) method Set

Defined as:

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

(Any) method SetHash

Defined as:

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

(Any) method Mix

Defined as:

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

(Any) method MixHash

Defined as:

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

(Any) method Supply

Defined as:

Coerce the invocant first to a `list` by applying the invocant's `.list` method, and then to a Supply.

(Any) method min

Defined As:

Coerces to Iterable and returns the numerically smallest 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 value is still the one returned from `min`.

(Any) method max

Defined As:

Coerces to Iterable and returns the numerically 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 value is still the one returned from `max`.

(Any) method minmax

Defined As:

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.

(Any) method minpairs

Defined As:

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

(Any) method maxpairs

Defined As:

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

(Any) method keys

Defined As:

For defined Any returns its keys after calling `list` on it, otherwise calls `list` and returns it.

(Any) method flatmap

Defined As:

Coerces the Any to a `list` by applying the `.list` method and uses `List.flatmap` on it.

In the case of Any, `Any.list` returns a 1-item list, as is shown.

(Any) method roll

Defined As:

Coerces the invocant Any to a `list` by applying the `.list` method and uses `List.roll` on it.

(Any) method pick

Defined As:

Coerces the Any to a `list` by applying the `.list` method and uses `List.pick` on it.

(Any) method skip

Defined As:

Creates a Seq from 1-item list's iterator and uses `Seq.skip` on it.

(Any) method prepend

Defined As:

Initializes Any variable as empty Array and calls `Array.prepend` on it.

(Any) method unshift

Defined As:

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

(Any) method first

Defined As:

Treats the `Any` as a 1-item list and uses `List.first` on it.

(Any) method unique

Defined As:

Treats the `Any` as a 1-item list and uses `List.unique` on it.

(Any) method repeated

Defined As:

Treats the `Any` as a 1-item list and uses `List.repeated` on it.

(Any) method squish

Defined As:

Treats the `Any` as a 1-item list and uses `List.squish` on it.

(Any) method permutations

Defined As:

Treats the `Any` as a 1-item list and uses `List.permutations` on it.

(Any) method categorize

Defined As:

Treats the `Any` as a 1-item list and uses `List.categorize` on it.

(Any) method classify

Defined As:

Treats the `Any` as a 1-item list and uses `List.classify` on it.

(Any) method pairs

Defined As:

Returns an empty List if the invocant is undefined, otherwise converts the invocant to a List via the `list` method and calls List.pairs on it:

(Any) method antipairs

Defined As:

Applies the method List.antipairs to the invocant, if it is defined, after having invoked `list` on it. If the invocant is not defined, it returns an empty List:

(Any) method kv

Defined As:

Returns an empty List if the invocant is not defined, otherwise it does invoke `list` on the invocant and then returns the result of List.kv on the latter:

(Any) method toggle

Defined as:

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" position, unless `:\$off` is set to a true value, in which case the initial state will be "off".

A Callable from the head of `@conditions` is taken (if any are available) and it becomes the current tester. Each value from the original sequence is tested by calling the tester Callable with that value. The state of our imaginary switch is set to the return value from the tester: if it's truthy, set switch to "on", otherwise set it to "off".

Whenever the switch is toggled (i.e. switched from "off" to "on" or from "on" to "off"), the current tester Callable is replaced by the next Callable in `@conditions`, if available, which will be used to test any further values. If no more tester Callables are available, the switch will remain in its current state until the end of iteration.

Since the toggle of the switch's state loads the next tester Callable, setting `:\$off` to a `True` value affects when first tester is discarded:

(Any) method tree

Defined As:

Returns the class if it's undefined or if it's not iterable, returns the result of applying the `tree` method to the elements if it's Iterable.

`.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.

The second prototype applies the `Whatever` code passed as arguments to every level in turn; the first argument will go to level 1 and so on. `tree` can, thus, be a great way to process complex all levels of complex, multi-level, data structures.

(Any) method nl-out

Defined As:

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

(Any) method invert

Defined As:

Returns an empty List.

(Any) method combinations

Defined As:

Treats the `Any` as a 1-item list and uses `List.combinations` on it.

(Any) method iterator

Defined As:

Coerces the `Any` to a `list` by applying the `.list` method and uses `iterator` on it.

(Any) method grep

Defined As:

Coerces the `Any` to a `list` by applying the `.list` method and uses `List.grep` on it.

Based on `\$matcher` value can be either `((Any))` or empty List.

(Any) method append

Defined As:

In the case the instance is not a positional-thing, it instantiate 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.

(Any) method values

Defined As:

Returns an empty List.

Defined As:

TODO

(Any) method cache

Defined As:

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

Routines supplied by class Mu

Bool inherits from class Mu, which provides the following methods:

(Mu) method defined

Declared as

Returns `False` on the type object, and `True` otherwise.

Very few types (like Failure) override `defined` to return `False` even for instances:

(Mu) routine defined

Declared as

invokes the `.defined` method on the object and returns its result.

(Mu) routine isa

Returns `True` if the invocant is an instance of class `\$type`, a subset type or a derived class (through inheritance) of `\$type`.

A more idiomatic way to do this is to use the smartmatch operator ~~ instead.

(Mu) routine does

Returns `True` if and only if the invocant conforms to type `\$type`.

Using the smart match operator ~~ is a more idiomatic alternative.

(Mu) routine Bool

Returns `False` on the type object, and `True` otherwise.

Many built-in types override this to be `False` for empty collections, the empty string or numerical zeros

(Mu) method Capture

Declared as:

Returns a Capture with named arguments corresponding to invocant's public attributes:

(Mu) method Str

Returns a string representation of the invocant, intended to be machine readable. Method `Str` warns on type objects, and produces the empty string.

(Mu) routine gist

Returns a string representation of the invocant, optimized for fast recognition by humans. As such lists will be truncated at 100 elements. Use `.perl` to get all elements.

The default `gist` method in `Mu` re-dispatches to the perl method for defined invocants, and returns the type name in parenthesis for type object invocants. Many built-in classes override the case of instances to something more specific that may truncate output.

`gist` is the method that say calls implicitly, so `say \$something` and `say \$something.gist` generally produce the same output.

(Mu) routine perl

Returns a Perlish representation of the object (i.e., can usually be re-evaluated with EVAL to regenerate the object). The exact output of `perl` is implementation specific, since there are generally many ways to write a Perl expression that produces a particular value

(Mu) method item

Forces the invocant to be evaluated in item context and returns the value of it.

(Mu) method self

Returns the object it is called on.

(Mu) method clone

Creates a shallow clone of the invocant, including shallow cloning of private attributes. Alternative values for public attributes can be provided via named arguments with names matching the attributes' names.

Note that `.clone` does not go the extra mile to shallow-copy `@.` and `%.` sigiled attributes and, if modified, the modifications will still be available in the original object:

To clone those, you could implement your own `.clone` that clones the appropriate attributes and passes the new values to `Mu.clone`, for example, via `nextwith`. Alternatively, your own `.clone` could clone self first (using `self.Mu::clone` or `callsame`) and then manipulate the clone as needed, before returning it.

(Mu) method new

Default method for constructing (create + initialize) new objects of a class. This method expects only named arguments which are then used to initialize attributes with accessors of the same name.

Classes may provide their own `new` method to override this default.

`new` triggers an object construction mechanism that calls submethods named `BUILD` in each class of an inheritance hierarchy, if they exist. See the documentation on object construction for more information.

(Mu) method bless

Lower-level object construction method than `new`.

Creates a new object of the same type as the invocant, uses the named arguments to initialize attributes, and returns the created object.

You can use this method when writing custom constructors:

(Though each time you write a custom constructor, remember that it makes subclassing harder).

(Mu) method CREATE

Allocates a new object of the same type as the invocant, without initializing any attributes.

(Mu) method print

Prints value to `\$*OUT` after stringification using `.Str` method without adding a newline at end.

(Mu) method put

Prints value to `\$*OUT`, adding a newline at end, and if necessary, stringifying non-`Str` object using the `.Str` method.

(Mu) method say

Prints value to `\$*OUT` after stringification using gist method with newline at end. To produce machine readable output use `.put`.

(Mu) method ACCEPTS

`ACCEPTS` is the method that smart matching with the infix ~~ operator and given/when invokes on the right-hand side (the matcher).

The `Mu:U` multi performs a type check. Returns `True` if `\$other` conforms to the invocant (which is always a type object or failure).

Note that there is no multi for defined invocants; this is to allow autothreading of junctions, which happens as a fallback mechanism when no direct candidate is available to dispatch to.

(Mu) method WHICH

Returns an object of type ObjAt which uniquely identifies the object. Value types override this method which makes sure that two equivalent objects return the same return value from `WHICH`.

(Mu) method WHERE

Returns an `Int` representing the memory address of the object.

(Mu) method WHY

Returns the attached Pod::Block::Declarator.

For instance:

See Pod declarator blocks for details about attaching Pod to variables, classes, functions, methods, etc.

(Mu) trait is export

Marks a type as being exported, that is, available to external users.

A user of a module or class automatically gets all the symbols imported that are marked as `is export`.

See Exporting and Selective Importing Modules for more details.

(Mu) method return

The method `return` will stop execution of a subroutine or method, run all relevant phasers and provide invocant as a return value to the caller. If a return type constraint is provided it will be checked unless the return value is `Nil`. A control exception is raised and can be caught with CONTROL.

(Mu) method return-rw

Same as method `return` except that `return-rw` returns a writable container to the invocant (see more details here: `return-rw`).

(Mu) method emit

Emits the invocant into the enclosing supply or react block.

(Mu) method take

Returns the invocant in the enclosing gather block.

(Mu) routine take

Takes the given item and passes it to the enclosing `gather` block.

(Mu) routine take-rw

Returns the given item to the enclosing `gather` block, without introducing a new container.

(Mu) method so

Returns a `Bool` value representing the logical non-negation of an expression. One can use this method similarly to the English sentence: "If that is so, then do this thing". For instance,

(Mu) method not

Returns a `Bool` value representing the logical negation of an expression. Thus it is the opposite of `so`.

Since there is also a prefix version of `not`, the above code reads better like so: