Skip to content

Instantly share code, notes, and snippets.

@KamilaBorowska
Created July 30, 2012 16:07
Show Gist options
  • Save KamilaBorowska/3208055 to your computer and use it in GitHub Desktop.
Save KamilaBorowska/3208055 to your computer and use it in GitHub Desktop.
== Str.wordcase ==
multi sub wordcase(Str:D :&filter = &lc, :%exceptions = set()) returns Str
multi method wordcase(Str:D: :&filter = &lc, :%exceptions = set()) returns Str
Performs a Unicode titlecase operation on the first character of each word of the string (as defined by a regex « boundary), and forces the rest of the letters through a filter that defaults to lc. After this operation, if any exceptions are supplied and if the word is found in the set of exceptions, the first character is also forced through the filter. Note that the exceptions must be spelled with an initial titlecase, such as "By" or "And", to produce "by" or "and".
== Date.day-of-year ==
method day-of-year(Date:D:) returns Int:D
Returns the day of the year (1..366).
== List.shift ==
multi sub shift(List:D )
multi method shift(List:D:)
Removes and returns the first item from the list, fails for an empty list.
== Pair.cmp ==
multi sub infix:<cmp>(Pair:D, Pair:D)
The type-agnostic comparator; compares two Pairs. Compares first their key parts, and then compares the value parts if the keys are equal.
== Rational.numerator ==
method numerator(Rational:D:) returns NuT:D
Returns the numerator.
== Mu.print ==
multi method print() returns Bool:D
Prints value to $*OUT after stringification using .Str method without newline at end.
== Numeric.exp ==
multi sub exp(Numeric:D, Numeric:D $base = e) returns Numeric:D
multi method exp(Numeric:D: Numeric:D $base = e) returns Numeric:D
Returns $base to the power of the number, or e to the power of the number if called without a second argument.
== Bool.prefix:<so> ==
multi sub prefix:<so>(Mu) returns Bool:D
Coerces its argument to Bool, has looser precedence than < prefix:<? >>.
== Complex.polar ==
method polar(Complex:D:) returns Positional:D
Returns a two-element list of the polar coordinates for this value, ie magnitude and angle in radians.
== Backtrace.full ==
multi method full(Backtrace:D:) returns Str:D:
Returns a full string representation of the backtrace, including hidden frames, compiler-specific frames and those from the setting.
== IO.modified ==
"path/to/file".IO.modified()
Timestamp when the file was last modified.
== Enum.value ==
multi method value(Enum:D:)
Returns the value part of the Enum.
== Pair.value ==
multi method value(Pair:D:) is rw
Returns the value part of the Pair.
== Str.tclc ==
multi sub tclc(Str:D ) returns Str:D
multi method tclc(Str:D:) returns Str:D
Turns the first character to title case, and all other characters to lower case
== Complex.isNaN ==
method isNaN(Complex:D:) returns Bool:D
Returns true if the real or imaginary part is NaN (not a number).
== List.sort ==
multi sub sort(*@elems) returns List:D
multi sub sort(&by, *@elems) returns List:D
multi method sort(List:D:) returns List:D
multi method sort(List:D:, &by) returns List:D
Sorts the list, smallest element first. By default < infix:<cmp >> is used for comparing list elements.
== List.end ==
multi sub end($list) returns Int:D
multi method end(List:D:) returns Int:D
Returns the index of the last element.
== Mu.defined ==
multi sub defined(Mu) returns Bool:D
multi method defined() returns Bool:D
Returns False on the type object, and True otherwise
== Str.chars ==
multi sub chars(Str:D ) returns Int:D
multi method chars(Str:D:) returns Int:D
Returns the number of characters in the string in the current (lexically scoped) idea of what a normal character is, usually graphemes.
== Range.min ==
method min(Range:D:)
Returns the start point of the range.
== Mu.gist ==
multi sub gist(Mu) returns Str
multi method gist() returns Str
Returns a string representation of the invocant, optimized for fast recognition by humans.
== Date.gist ==
multi method gist(Date:D:) returns Str:D
Returns the date in YYYY-MM-DD format (ISO 8601)
== Exception.gist ==
multi method gist(Exception:D:)
Returns whatever the exception printer should produce for this exception. The default implementation returns message and backtrace separated by a newline.
== Str.ord ==
multi sub ord (Str:D) returns Int:D
multi method ord(Str:D:) returns Int:D
Returns the codepoint number of the first character of the string
== Str.lc ==
multi sub lc(Str:D ) returns Str:D
multi method lc(Str:D:) returns Str:D
Returns a lower-case version of the string.
== Numeric.abs ==
multi sub abs(Numeric:D ) returns Real:D
multi method abs(Numeric:D:) returns Real:D
Returns the absolute value of the number.
== Str.tc ==
multi sub tc(Str:D ) returns Str:D
multi method tc(Str:D:) returns Str:D
Does a Unicode "titlecase" operation, that is changes the first character in the string to title case, or to upper case if the character has no title case mapping
== Backtrace::Frame.is-setting ==
method is-setting(Backtrace::Frame:D) return Bool:D
Returns True if the frame is part of a setting.
== Numeric.sqrt ==
mulit sub sqrt(Numeric:D) returns Numeric:D
mulit method sqrt(Numeric:D) returns Numeric:D
Returns a square root of the number. For real numbers the positive square root is returned.
== List.pairs ==
multi sub pairs($list) returns List:D
multi method pairs(List:D:) returns List:D
Returns a list of pairs, with the indexes as keys and the list values as values.
== Pair.pairs ==
multi method pairs(Pair:D:)
Returns a list of one Pair, namely this one.
== EnumMap.pairs ==
method pairs(EnumMap:D:) returns List:D
Returns a list of all pairs in the EnumMap.
== Numeric.Real ==
method Real(Numeric:D:) returns Real:D
If this Numeric is equivalent to a Real, return that Real. Fail with X::Numeric::Real otherwise.
== Mu.ACCEPTS ==
multi method ACCEPTS(Mu:U: $other)
Performs a type check. Returns True if $other conforms to the invocant (which is always a type object or failure).
== Any.ACCEPTS ==
multi method ACCEPTS(Any:D: Mu $other)
Returns True if $other === self (ie it checks object identity).
== Code.ACCEPTS ==
multi method ACCEPTS(Code:D: Mu $topic)
Usually calls the code object and passes $topic as an argument. However, when called on a code object that takes no arguments, the code object is invoked with no arguments and $topic is dropped. The result of the call is returned.
== Numeric.ACCEPTS ==
multi method ACCEPTS(Numeric:D: $other)
Returns True if $other is numerically the same as the invocant.
== EnumMap.ACCEPTS ==
multi method ACCEPTS(EnumMap:D: Positional $topic)
multi method ACCEPTS(EnumMap:D: Cool:D $topic)
multi method ACCEPTS(EnumMap:D: Regex $topic)
multi method ACCEPTS(EnumMap:D: Any $topic)
Used in smart-matching if the right-hand side is an EnumMap.
== Mu.perl ==
multi sub perl(Mu) returns Str
multi method perl() returns Str
Returns a Perlish representation of the object (i.e., can usually be reparsed to regenerate the object).
== Date.year ==
method year(Date:D:) returns Int:D
Returns the year of the date
== Range.excludes_max ==
method excludes_max(Range:D:) returns Bool:D
Returns True if the end point is excluded from the range, and False otherwise.
== Str.chomp ==
multi sub chomp(Str:D ) returns Str:D
multi method chomp(Str:D:) returns Str:D
Returns the string with a logical newline removed from the end.
== Mu.bless ==
method bless(Mu $candidate, *%attrinit) returns Mu:D
Lower-level object construction method than new.
== Str.encode ==
multi method encode(Str:D: $encoding = $?ENC, $nf = $?NF) returns Buf
Returns a Buf which represents the original string in the given encoding and normal form. The actual return type is as specific as possible, so $str.encode('UTF-8') returns a utf8 object, $str.encode('ISO-8859-1') a buf8.
== Mu.say ==
multi method say() returns Bool:D
Prints value to $*OUT after stringification using .gist method with newline at end.
== Date.is-leap-year ==
method is-leap-year($year = self.year) returns Bool:D
Returns True if $year is a leap year. Can be called as a class method if the year is provided.
== Mu.Bool ==
multi sub Bool(Mu) returns Bool:D
multi method Bool() returns Bool:D
Returns False on the type object, and True otherwise
== Numeric.Bool ==
multi method Bool(Numeric:D:)
Returns False if the number is equivalent to zero, and True otherwise.
== Buf.Bool ==
multi method Bool(Buf:D:)
Returns False if and only if the buffer is empty.
== List.Bool ==
multi method Bool(List:D:) returns Bool:D
Returns True if the list has at least one element, and False for the empty list.
== Buf.elems ==
multi method elems(Buf:D:) returns Int:D
Returns the number of elements of the buffer.
== List.elems ==
multi sub elems($list) returns Int:D
multi method elems(List:D:) returns Int:D
Returns the number of elements in the list.
== EnumMap.elems ==
method elems(EnumMap:D:) returns Int:D:
Returns the number of pairs stored in the EnumMap.
== Exception.fail ==
method fail(Exception:D:)
Same as fail $exception; i.e., it exits the calling Routine and returns the exception wrapped in a Failure object.
== Date.days-in-month ==
method days-in-month(year = self.year, month = self.month) returns Int:D
Returns the number of days in a month, where year and month default to that of the invocant. If both year and month are provided, it can be called as a class method.
== Date.prev ==
method prev(Date:D:) return Date:D
Returns the previous day
== List.roll ==
multi method roll(List:D: $count = 1)
Returns a lazy list of $count elements, each randomly selected from the list. Each random choice is made indepently, like a separate die roll where each die face is a list element.
== Numeric.conj ==
multi method conj(Numeric:D) returns Numeric:D
Returns the complex conjugate of the number. Returns the number itself for real numbers.
== Mu.Str ==
multi method Str() returns Str
Returns a string representation of the invocant, intended to be machine readable.
== Code.Str ==
multi method Str(Code:D:) returns Str:D
Returns the name of the code object.
== Match.Str ==
sub marine() { }
say ~&marine; # marine
Returns the matched text.
== Date.Str ==
multi method Str(Date:D:) returns Str:D
Returns the date in YYYY-MM-DD format (ISO 8601)
== List.Str ==
multi method Str(List:D:) returns Str:D
Stringifies the elements of the list and joins them with spaces (same as .join(' ')).
== Backtrace.Str ==
multi method Str(Backtrace:D:) returns Str:D:
Returns a concise string representation of the backtrace, omitting routines marked as is hidden_from_backtrace, and at the discretion of the implementor, also some routines from the setting.
== Range.bounds ==
method bounds(Range:D:) returns Positional
Returns a list consisting of the start and end point.
== Rational.denominator ==
method denominator(Rational:D:) returns DenomT:D
Returns the denominator.
== IO.accessed ==
"path/to/file".IO.accessed()
Timestamp when the file was last accessed.
== Str.fc ==
multi sub fc(Str:D ) returns Str:D
multi method fc(Str:D:) returns Str:D
Does a Unicode "fold case" operation suitable for doing caseless string comparisons. (In general, the returned string is unlikely to be useful for any purpose other than comparison.)
== Code.count ==
method count(Code:D:) returns Real:D
Returns the maximum number of positional arguments that may be passed when calling the code object. For code objects that can accept any number of positional arguments (that is, they have a slurpy parameter), count will return Inf. Named parameters do not contribute.
== Signature.count ==
method count(Signature:D:) returns Real:D
Returns the maximal number of positional arguments which can be bound to the signature. Returns Inf if there is a slurpy positional parameter.
== Backtrace::Frame.subname ==
method subname(Backtrace::Frame:D) returns Str
Returns the name of the enclosing subroutine.
== Str.split ==
multi method split(Str:D $input: Str:D $delimiter, $limit = Inf, :$all) returns Positional
multi method split(Str:D $input: Regex:D $delimiter, $limit = Inf, :$all) returns Positional
Splits a string up into pieces based on delimiters found in the string.
== List.values ==
multi sub values($list) returns List:D
multi method values(List:D:) returns List:D
Returns a copy of the list.
== EnumMap.values ==
method values(EnumMap:D:) returns List:D
Returns a list of all values in the EnumMap.
== Exception.backtrace ==
method backtrace(Exception:D:) returns Backtrace:D
Returns the backtrace associated with the exception. Only makes sense on exceptions that have been thrown at least once.
== List.kv ==
multi sub kv($list) returns List:D
multi method kv(List:D:) returns List:D
Returns an interleaved list of indexes and values. For example
== Pair.kv ==
multi method kv(Pair:D:) returns Parcel:D
Returns a two-element Parcel with the key and value parts o Pair, in that order. This method is a special case of the same-named method on Hash, which returns all its entries as a list of keys and values.
== EnumMap.kv ==
method kv(EnumMap:D:) returns List:D
Returns a list of keys and values interleaved.
== Str.chop ==
multi sub chop(Str:D) returns Str:D
multi method chop(Str:D:) returns Str:D
Returns the string with one character removed from the end.
== List.reverse ==
multi sub reverse(*@list ) returns List:D
multi method reverse(List:D:) returns List:D
Returns a list with the elements in reverse order.
== Str.sprintf ==
multi sub sprintf ( Str:D $format, *@args) returns Str:D
This function is mostly identical to the C library sprintf function.
== Real.ceiling ==
method ceiling(Real:D) returns Int:D
Returns the smallest integer not less than the number.
== Code.arity ==
method arity(Code:D:) returns Int:D
Returns the minimum number of positional arguments that must be passed in order to call the code object. Any optional or slurpy parameters in the code object's Signature do not contribute, nor do named parameters.
== Signature.arity ==
method arity(Signature:D:) returns Int:D
Returns the minimal number of positional arguments required to satisfy the signature.
== Pair.fmt ==
multi method fmt(Pair:D:) returns Str:D
Takes a format string, and returns a string the key and value parts of the Pair formatted. Here's an example:
== Real.base ==
method base(Real:D: Int:D $base where 2..36) returns Str:D
Converts the number to a string, using $base as base. For $base larger than ten, capital latin letters are used.
== Date.day-of-month ==
method day-of-month(Date:D:) returns Int:D
Returns the day of the month of the date (1..31). Synonymous to the day method.
== Numeric.log10 ==
multi sub log10(Numeric:D ) returns Numeric:D
multi method log10(Numeric:D:) returns Numeric:D
Calculates the logarithm to base 10.
== Real.sign ==
method sign(Real:D:)
Returns -1 if the number is negative, 0 if it is zero and 1 otherwise.
== Rational.norm ==
method norm(Rational:D:) returns Rational:D
Returns a normalized Rational object, ie with positive denominator, and numerator and denominator coprime.
== Enum.invert ==
multi method invert(Enum:D:) returns Enum:D
Returns a new Enum with the original enum's value as the key, and the original enum's key as value.
== EnumMap.invert ==
method invert(EnumMap:D:) returns List:D
Returns a list of pairs, but with key and value exchanged.
== IO.dir ==
sub dir Cool $path = '.', Mu :$test = none('.', '..')
Returns a list of IO::File and IO::Dir objects for the files and directories found in the $path. If $path is not given assumes the current directory.
== Parameter.type_captures ==
sub a(::T ::U $x) { }
say &a.signature.params[0].type_captures; # T U
Returns a list of variable names of type captures associated with this parameter
== Complex.re ==
method re(Complex:D:) returns Real:D
Returns the real part of the complex number.
== Range.list ==
method list(Range:D:) returns List:D
Returns a list of positional submatches.
== Str.trim ==
method trim(Str:D:) returns Str
Remove leading and trailing white-spces. It can be use both as a method on strings and as a function. When used as a method it will return the trimmed string. In order to do in-place trimming, once needs to write .=trim
== Backtrace::Frame.code ==
method code(Backtrace::Frame:D)
Returns the code object into which .file and .line point, if avaialble.
== Numeric.Num ==
method Num(Numeric:D:) returns Num:D
If this Numeric is equivalent to a Real, return that Real as a Num as accurately as is possible. Fail with X::Numeric::Real otherwise.
== List.map ==
multi sub map(&code, *@elems) returns List:D
multi method map(List:D: &code) returns List:D
Invokes &code for each element and gathers the return values in another list and returns it. This happens lazily, ie &code is only invoked when the return values are accessed.
== Range.max ==
method max(Range:D:)
Returns the end point of the range.
== Match.make ==
method make(Match:D: Mu $ast)
Sets the AST to $ast, and returns it.
== Mu.CREATE ==
method CREATE() returns Mu:D
Allocates a new object of the same type as the invocant, without initializating any attributes.
== Real.round ==
method round(Real:D: $scale = 1)
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.
== Positional.of ==
method of()
Returns the type constraint for elements of the positional container. Defaults to Mu.
== List.push ==
multi sub push(List:D, *@values) returns List:D
multi method push(List:D: *@values) returns List:D
Adds the @values to the end of the list, and returns the modified list. Fails for infinite lists.
== Hash.push ==
multi method push(Hash:D: *@new)
Adds the @new elements to the hash with the same semantics as hash assignment, but with three exceptions:
== Numeric.Int ==
method Int(Numeric:D:) returns Int:D
If this Numeric is equivalent to a Real, return the equivalent of calling truncate on that Real to get an Int. Fail with X::Numeric::Real otherwise.
== List.Int ==
multi method Int(List:D:) return Int:D
Returns the number of elements in the list (same as .elems).
== Exception.throw ==
method throw(Exception:D:)
Throws the exception.
== Backtrace::Frame.file ==
method file(Backtrace::Frame:D) returns Str
Returns the file name.
== Str.index ==
multi sub index(Str:D, Str:D $needle, Int $startpos = 0) returns StrPos
multi method index(Str:D: Str:D $needle, Int $startpos = 0) returns StrPos
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.
== Str.ords ==
multi method ords(Str:D:) returns Positional
Returns a list of codepoint numbers, one for each character in the string.
== Real.truncate ==
method truncate(Real:D) returns Int:D
Rounds the number towards zero.
== IO.prompt ==
my $name = prompt("Hi, what's your name?");
Prints out a string to the standard output and waits for the user to type in something and finish with an ENTER. Returns the string typed in without the trailing newline.
== Date.day-of-week ==
method day-of-week(Date:D:) returns Int:D
Returns the day of the week, where 0 is Sunday, 1 is Monday etc.
== Real.rand ==
sub term:<rand> returns Num:D
method rand(Real:D:) returns Real:D
Returns a pseudo-random number between zero and the number.
== Str.uc ==
multi sub uc(Str:D ) returns Str:D
multi method uc(Str:D:) returns Str:D
Returns an uppercase version of the string.
== Exception.rethrow ==
method rethrow(Exception:D:)
Rethrows an exception that has already been thrown at least once. This is different from throw in that it preserves the original backtrace.
== List.pick ==
multi method pick(List:D: $count = 1)
Returns $count elements chosen at random and without repetition from the invocant. If * is passed as $count, all elements from the invocant list are returned in a random sequence.
== Str.substr ==
multi sub substr(Str:D $s, Int:D $from, Int:D $chars = $s.chars - $from) returns Str:D
multi method substr(Str:D $s: Int:D $from, Int:D $chars = $s.chars - $from) returns Str:D
Returns a part of the string, starting from the character with index $from (where the first character has index 0) and with length $chars.
== Str.pred ==
method pred(Str:D:) returns Str:D
Returns the string decremented by one.
== Numeric.pred ==
method pred(Numerid:D:)
Returns the number decremented by one (predecessor).
== List.eager ==
multi method eager(List:D:) returns List:D
Evaluates all elements in the list eagerly, and returns the invocant. If a List signals that it is "known infinite", eager evaluation may stop at the point where the infinity is detected.
== List.keys ==
multi sub keys($list) returns List:D
multi method keys(List:D:) returns List:D
Returns a list of indexes into the list (i.e., 0..(@list.elems-1)).
== EnumMap.keys ==
method keys(EnumMap:D:) returns List:D
Returns a list of all keys in the EnumMap.
== List.pop ==
multi sub pop(List:D )
multi method pop(List:D:)
Removes and returns the last item from the list, fails for an empty list.
== Complex.im ==
method im(Complex:D:) returns Real:D
Returns the imaginary part of the complex number.
== Bool.prefix:<?> ==
multi sub prefix:<?>(Mu) returns Bool:D
Coerces its argument to Bool.
== List.unshift ==
multi sub unshift(List:D, *@values) returns List:D
multi method unshift(List:D: *@values) returns List:D
Adds the @values to the start of the list, and returns the modified list. Fails if @values is infinite.
== Str.tcuc ==
multi sub tcuc(Str:D ) returns Str:D
multi method tcuc(Str:D:) returns Str:D
Turns the first character to title case, and all other characters to upper case
== Str.comb ==
multi sub comb(Str:D $matcher, Str:D $input, $limit = Inf, Bool :$match)
multi sub comb(Regex:D $matcher, Str:D $input, $limit = Inf, Bool :$match)
multi method comb(Str:D $input:)
multi method comb(Str:D $input: Str:D $matcher, $limit = Inf, Bool :$match)
multi method comb(Str:D $input: Regex:D $matcher, $limit = Inf, Bool :$match)
Searches for $matcher in $input and returns a list of all matches (as Str by default, or as Match if $match is True), limited to at most $limit matches.
== Exception.message ==
method message(Exception:D:) returns Str:D
This is a stub that must be overwritten by subclasses, and should return the exception message.
== Backtrace::Frame.line ==
method line(Backtrace::Frame:D) returns Int
Returns the line number (line numbers start to count from 1).
== Real.floor ==
method floor(Real:D) returns Int:D
Return the largest integer not greater than the number.
== Backtrace::Frame.is-routine ==
method is-routine(Backtrace::Frame:D) return Bool:D
Return True if the frame point into a routine (and not into a mere Block).
== Numeric.Rat ==
method Rat(Numeric:D: Real $epsilon = 1.0e-6) returns Rat:D
If this Numeric is equivalent to a Real, return a Rat which is within $epsilon of that Real's value. Fail with X::Numeric::Real otherwise.
== Real.Rat ==
method Rat(Real:D: Real $epsilon = 1e-6)
Converts the number to a Rat with the precision $epsilon.
== List.rotate ==
multi sub rotate(@list, Int:D $n = 1) returns List:D
multi method rotate(List:D: Int:D $n = 1) returns List:D
Returns the list rotated by $n elements.
== Date.day ==
method day(Date:D:) returns Int:D
Returns the day of the month of the date (1..31)
== X::AdHoc.payload ==
method payload(X::AdHoc:D)
Returns the original object which was passed to die.
== Backtrace::Frame.is-hidden ==
method is-hidden(Backtrace::Frame:D) return Bool:D
Returns True if the frame is marked as hidden with the is hidden_from_backtrace trait.
== Str.words ==
multi sub words(Str:D $input, $limit = Inf) returns Positional
multi method words(Str:D $input: $limit = Inf) returns Positional
Returns a list of non-whitespace bits, i.e. the same as a call to $input.comb( / \S+ /, $limit ) would.
== Str.succ ==
method succ(Str:D) returns Str:D
Returns the string incremented by one.
== Numeric.succ ==
method succ(Numerid:D:)
Returns the number incremented by one (successor).
== Date.succ ==
method succ(Date:D:) returns Date:D
Returns the following day
== Mu.clone ==
method clone(*%twiddles)
Creates a shallow clone of the invocant. If named arguments are passed to it, their values are used in every place where an attribute name matches the name of a named argument.
== List.splice ==
multi sub splice(@list, $start, $elems? *@replacement) returns List:D
multi method splice(List:D: $start, $elems? *@replacement) returns List:D
Deletes $elems elements starting from index $start from the list, returns them and replaces them by @replacement. If $elems is omitted, all the elements starting from index $start are deleted.
== IO.changed ==
"path/to/file".IO.changed()
Timestamp when the inode was last changed.
== Date.today ==
method today() returns Date:D
Returns a Date object for the current day.
== Str.flip ==
multi sub flip(Str:D ) returns Str:D
multi method flip(Str:D:) returns Str:D
Returns the string reversed character by character.
== Range.flat ==
method flat(Range:D:) returns List:D
Generates the list of elements that the range represents.
== Str.rindex ==
multi sub rindex(Str:D $haystack, Str:D $needle, Int $startpos = $haystack.chars) returns StrPos
multi method rindex(Str:D $haystack: Str:D $needle, Int $startpos = $haystack.chars) returns StrPos
Returns the last position of $needle in $haystack not after $startpos. Returns an undefined value if $needle wasn't found.
== Code.signature ==
multi method signature(Code:D:) returns Signature:D
Returns the Signature object for this code object, which describes its parameters.
== Rational.nude ==
method nude(Rational:D:) returns Positional
Returns a list of the numerator and denominator.
== List.first ==
multi sub first(Mu $matcher, *@elems)
multi method first(List:D: Mu $matcher)
Returns the first item of the list which smart-matches against $matcher.
== Buf.decode ==
multi method decode(Buf:D: Str:D $encoding = 'UTF-8') returns Str:D
Applies an encoding to turn the buffer into a Str.
== Signature.params ==
method params(Signature:D:) returns Positional
Returns the list of Parameter objects that make up the signature.
== Parameter.parcel ==
sub f(\$parcel, $non-parcel) { }
Returns True for parcel parameters
== Numeric.log ==
multi sub log(Numeric:D, Numeric $base = e) returns Numeric:D
multi method log(Numeric:D: Numeric $base = e) returns Numeric:D
Calculates the logarithm to base $base. Defaults to the natural logarithm.
== Int.div ==
multi sub infix:<div>(Int:D, Int:D) returns Int:D
Does an integer division, rounded down.
== Str.lines ==
multi sub lines(Str:D $input, $limit = Inf) returns Positional
multi method lines(Str:D $input: $limit = Inf) returns Positional
Returns a list of lines (without trailing newline characters), i.e. the same as a call to $input.comb( / ^^ \N* /, $limit ) would.
== Mu.new ==
multi method new(*%attrinit)
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.
== Complex.new ==
proto method new(*@, *%) {*} returns Complex:D
multi method new(Real $re, Real $im) returns Complex:D
Creates a new Complex object from real and imaginary parts.
== Rational.new ==
method new(NuT:D $numerator, DenomT:D $denominator) returns Rational:D
Creates a new rational object from numerator and denominator.
== Date.new ==
proto method new() {*}
multi method new($year, $month, $day) returns Date:D
multi method new(:$year, :$month, :$day) returns Date:D
multi method new(Str $date) returns Date:D
multi method new(DateTime:D $dt) returns Date:D
Creates a new Date object, either from a tripple of (year, month, day) integers, or from a string of the form YYYY-MM-DD (ISO 8601), or from a DateTime object.
== Buf.new ==
method new(*@codes)
Creates a Buf from a list of integers.
== Backtrace.new ==
proto method new(*@, *%) {*}
multi method new()
From Backtrace
== List.grep ==
multi sub grep(Mu $matcher, *@elems) returns List:D
multi method grep(List:D: Mu $matcher) returns List:D
Returns a lazy list of elements against which $matcher smart-matches. The elements are returned in the order in which they appear in the original list.
== List.join ==
multi sub join($separator, *@list) returns Str:D
multi method join(List:D: $separator) returns Str:D
Treats the elements of the list as strings, interleaves them with $separator and concatenates everything into a single string.
== List.reduce ==
multi sub reduce(&with, *@elems)
multi method reduce(List:D: &with)
Applies &with to the first and the second value of the list, then to result of that calculation and the third value and so on. Returns a single item generated that way.
== Enum.key ==
multi method key(Enum:D:)
Returns the key part of the Enum.
== Range.excludes_min ==
method excludes_min(Range:D:) returns Bool:D
Returns True if the start point is excluded from the range, and False otherwise.
== List.classify ==
multi sub classify(&mapper, *@values) returns Hash:D
multi method classify(List:D: &mapper) returns Hash:D
classify transforms a list or array of values into a hash representing the classification of those values according to a mapper; each hash key represents the classification for one or more of the incoming list values, and the corresponding hash value contains an array of those list values classified by the mapper into the category of the associated key. For example:
== Numeric.roots ==
multi method roots(Numeric:D: Int:D $n) returns Positional
Returns a list of the $n complex roots, which evaluate to the original number when raised to the $nth power.
== Parameter.capture ==
sub f(\capture) { }
Returns True for parameters that capture the rest of the argument list
== Date.month ==
method month(Date:D:) returns Int:D
Returns the month of the date (1..12)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment