Skip to content

Instantly share code, notes, and snippets.

@dogbert17
dogbert17 / gist:6deed8b9776bacb444b18faaae08ebf1
Created April 16, 2016 10:37
Additions to the method coercion table in Cool.pos
The following table summarizes the methods that Cool provides, and what type they coerce to:
...
chomp Str
chop Str
codes Str
Int Int
Num Num
Rat Rat
Real Real
UInt UInt
@dogbert17
dogbert17 / euler-28.pl6
Created April 16, 2016 17:17
Causes problems when run with the --profile option
# What is the sum of the numbers on the diagonals in a 1001 by 1001 spiral formed in the same way?
# real 10m52.262s
# user 10m37.848s
# sys 0m1.068s
# This is Rakudo version 2016.03-76-gb3b24bf built on MoarVM version 2016.03-84-g4afd7b6
use v6;
my $size = 5;
my @mat[$size; $size];
init-array(0, $size - 1, $size * $size);
@dogbert17
dogbert17 / gist:669dbab640ad74ec98ce3451a17428e8
Last active April 18, 2016 19:05
Newbie attempt at creating documentation for the samecase method. Some inspiration from http://search.cpan.org/~moritz/Perl6-Str-v0.0.5/lib/Perl6/Str.pm
=head2 routine samecase
Defined as:
sub samecase(Cool $string, Cool $pattern)
method samecase(Cool:D: Cool $pattern)
Usage:
samecase STRING, PATTERN
@dogbert17
dogbert17 / gist:dcb38d4248d044a48cb32ebf622d01e1
Last active April 23, 2016 11:38
Preliminary attempt to document the method unpolar in Cool.pod
=head2 method unpolar
Defined as:
method unpolar(Numeric(Cool))
Usage:
unpolar NUMERIC, NUMERIC
NUMERIC.unpolar(NUMERIC)
@dogbert17
dogbert17 / gist:3135be4f816ec758fd1d294fbb551099
Last active April 24, 2016 10:45
Preliminary attempt to document the polymod method in Int.pod
=head2 routine polymod
Defined as:
method polymod(Int:D: +@mods)
Usage:
INTEGER.polymod(LIST) # Is this correct ?
@dogbert17
dogbert17 / gist:caa982701d8276c034a029a194c21eca
Last active April 26, 2016 21:11
Attempt to document the sum method in List.pm
=head2 routine sum
Defined as:
multi sub sum($list) returns Numeric:D
multi method sum(List:D:) returns Numeric:D
Usage:
sum LIST
@dogbert17
dogbert17 / gist:829e1adf6c6f9b03f2f47d9eb1a2c72e
Last active May 7, 2016 17:11
Formatter examples (Dateish.pod)
=head2 method formatter
Defined as:
method formatter(Dateish:D:)
Usage:
Dateish.formatter
@dogbert17
dogbert17 / gist:b5625897cf557437ed5b0e40b96c12de
Last active May 8, 2016 12:43
Trying to write some docs for Instant.from-posix and Instant.to-posix
=head1 Methods
=head2 method from-posix
method from-posix($posix, Bool $prefer-leap-second = False)
Converts the POSIX timestamp C<$posix> to an Instant.
If C<$prefer-leap-second> is C<True>, the return value will be
the first of the two possible seconds in the case of a leap second.
@dogbert17
dogbert17 / gist:81529690ccf4ded4f00be96faf999b0c
Last active May 11, 2016 21:16
Attempt to write some docs for Pair.freeze - perhaps more text is needed
=head2 method freeze
Defined as:
method freeze(Pair:D:)
Usage:
PAIR.freeze
@dogbert17
dogbert17 / gist:cce803676b3fb98952e3215bc2d71d91
Created May 14, 2016 14:41
Attempt to document X::Promise::Vowed
=begin pod
=TITLE class X::Promise::Vowed
=SUBTITLE Error due to directly trying to keep/break a vowed promise.
class X::Promise::Vowed is Exception { }
This exception is thrown when code tries to keep/break an already vowed
promise without going through the corresponding C<Vow> object.