This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=head2 method of | |
Defined as: | |
method of | |
Usage: | |
Hash.of |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=head2 method default | |
Defined as: | |
method default | |
Usage: | |
Array.default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=head2 method print-nl | |
method print-nl(IO::Handle:D: --> True) | |
Writes a newline to the filehandle. The newline marker defaults | |
to C<\n> unless another marker has been specified in the call to | |
L<open>. | |
my $fh = open 'path/to/file', :w, nl-out => "\r\n"; | |
$fh.print("some text"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=head2 routine does | |
method does(Mu $type) returns Bool:D | |
Returns True if and only if the invocant conforms to type C<$type>. | |
my $d = Date.new('2016-06-03'); | |
say $d.does(Dateish); # True (Date does role Dateish) | |
say $d.does(Any); # True (Date is a subclass of Any) | |
say $d.does(DateTime); # False (Date is not a subclass of DateTime) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=head2 routine categorize | |
Defined as: | |
multi sub categorize(&mapper, *@values) returns Hash:D | |
multi method categorize(List:D: &mapper) returns Hash:D | |
Usage: | |
categorize MAPPER, LIST |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=head2 method kxxv | |
Defined as: | |
method kxxv(Baggy:D:) returns List:D | |
Returns a list of the keys of the invocant, with each key multiplied by its | |
weight. Note that C<kxxv> only works for C<Baggy> types which have integer | |
weights, i.e. L<Bag> and L<BagHash>. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is Rakudo version 2016.05-79-g2095ed6 built on MoarVM version 2016.05-17-g6075599 implementing Perl 6.c. | |
# What is the value of the first triangle number to have over five hundred divisors? | |
use v6; | |
my $numFactors = 500; | |
my $sum = 0; | |
for (1...*) -> $term { | |
$sum += $term; | |
my $factors = (1..floor(sqrt($sum))).grep(-> $x { $sum % $x == 0} ).elems * 2; | |
$factors-- if floor(sqrt($sum)) == sqrt($sum); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dogbert@dogbert-VirtualBox ~ $ time perl6-valgrind-m euler-12.pl6 | |
================================================================================================ | |
This is Rakudo Perl 6 running in valgrind, a tool for debugging and profiling programs. | |
Running a program in valgrind usually takes *a lot* more time than running it directly, | |
so please be patient. | |
This Rakudo version is 2016.05.79.g.2095.ed.6 built on MoarVM version 2016.05.17.g.6075599, | |
running on ubuntu (14.04.3.LTS.Trusty.Tahr) / linux (3.19.0.32.generic) | |
------------------------------------------------------------------------------------------------ | |
==7688== Memcheck, a memory error detector | |
==7688== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=head2 method elems | |
Defined as: | |
method elems(Baggy:D:) returns Int:D | |
Returns the number of elements in the C<Baggy> object without | |
taking the individual elements weight into account. | |
my $breakfast = bag <eggs spam spam spam>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=head2 method keys | |
Defined as: | |
method keys(Baggy:D:) returns List:D | |
Returns a list of all keys in the C<Baggy> object without taking | |
their individual weights into account as opposed to L<kxxv|#method kxxv>. | |
my $breakfast = bag <eggs spam spam spam>; |