Skip to content

Instantly share code, notes, and snippets.

@dogbert17
dogbert17 / gist:cb137b3fa751b853bda38f5750540ce0
Last active June 11, 2016 15:21
Attempt to document Baggy.roll. Most of the text is taken directly from https://design.perl6.org/S32/Containers.html#Bag
=head2 method roll
Defined as:
multi method roll(Baggy:D:) returns Any:D
multi method roll(Baggy:D: $count) returns Seq:D
Like an ordinary list L<roll|/type/List/#routine_roll>, but returns keys of the invocant weighted
by their values, as if the keys were replicated the number of times indicated
by the corresponding value and then list roll used. The underlying
@dogbert17
dogbert17 / gist:06d296160772002c93029bd90b1d6874
Created June 14, 2016 19:41
Attempt to document Baggy.pick
=head2 method pick
Defined as:
multi method pick(Baggy:D:) returns Any
multi method pick(Baggy:D: $count) returns Seq:D
Like an ordinary list L<pick|/type/List#routine_pick>, but returns keys
of the invocant weighted by their values, as if the keys were replicated
the number of times indicated by the corresponding value and then list
@dogbert17
dogbert17 / gist:3ded7cb21226fde31a09ba774980606f
Created June 15, 2016 19:26
Attempt to document Baggy.pickpairs
=head2 method pickpairs
Defined as:
multi method pickpairs(Baggy:D:) returns Pair:D
multi method pickpairs(Baggy:D: $count) returns List:D
Returns a C<Pair> or a C<List> of C<Pair>s depending on the version of the method
being invoked. Each C<Pair> returned has an element of the invocant as its key and the
elements weight as its value. The elements are 'picked' without replacement. If C<*>
@dogbert17
dogbert17 / gist:0f5a38acd1c385629d604dd480398b82
Created June 16, 2016 19:17
Attempt to document method grabpairs in role Baggy
=head2 method grabpairs
Defined as:
multi method grabpairs(Baggy:D:) returns Any
multi method grabpairs(Baggy:D: $count) returns List:D
Returns a C<Pair> or a C<List> of C<Pair>s depending on the version of the method
being invoked. Each C<Pair> returned has an element of the invocant as its key and the
elements weight as its value. Unlike L<pickpairs>, it works only on mutable structures,
@dogbert17
dogbert17 / gist:efcb4849920629c281f0b8942b42fbf3
Last active June 20, 2016 19:11
Attempt to document Baggy.pairs
=head2 method pairs
Defined as:
method pairs(Baggy:D:) returns Seq:D
Returns all elements and their respective weights as a L<Seq|/type/Seq> of C<Pair>s
where the key is the element itself and the value is the weight of that element.
my $breakfast = bag <bacon eggs bacon>;
@dogbert17
dogbert17 / gist:8f9272fe0ac15d82e6cc065372603b9b
Created June 20, 2016 19:52
Attempt to document Baggy.antipairs
=head2 method antipairs
Defined as:
method antipairs(Baggy:D:) returns Seq:D
Returns all elements and their respective weights as a L<Seq|/type/Seq> of C<Pair>s
where the element itself is the value and the weight of that element is the key, i.e.
the opposite of method L<pairs|#method pairs>.
@dogbert17
dogbert17 / gist:56d39157e503843a0708f646f9261355
Created June 24, 2016 12:00
Attempt to document Map.antipairs
=head2 method antipairs
Defined as:
method antipairs(Map:D:) returns Seq:D
Returns all keys and their respective values as a L<Seq|/type/Seq> of C<Pair>s
where the keys and values have been exchanged, i.e. the opposite of method
L<pairs|#method_pairs>. Unlike the L<invert|#method_invert> method, there is
no attempt to expand list values into multiple pairs.
@dogbert17
dogbert17 / gist:7b3fc5bfe95fb3926fc82cabc3f8bbd9
Last active June 25, 2016 13:43
Trying to debug precomp problem with htmlify.p6
# I have made changes to Map.pod which are not shown on doc.perl6.org nor locally after having run htmlify.doc
# here's the timestamp for my copy of doc/Type/Map.pod
Cdogbert@dogbert-VirtualBox ~/repos/doc $ ls -l doc/Type/Map.pod
-rw-r--r-- 1 dogbert dogbert 4599 Jun 25 13:54 doc/Type/Map.pod
# running htmlify.p6 with the env var RAKUDO_MODULE_DEBUG=1 yields interesting results
46/240: doc/Type/Map.pod => type/Map
extract-pod: doc/Type/Map.pod which was modified 2016-06-25T11:54:25.455538Z # this printout added by dogbert17
=head2 method minmax
Defined as:
multi method minmax(Range:D:) returns List:D
If the C<Range> is an integer range (as indicated by L<is-int>), then this
method returns a list with the first and last value it will iterate over
(taking into account L<excludes-min> and L<excludes-max>). If the range is
not an integer range, the method will return a two element list containing
@dogbert17
dogbert17 / gist:ad42869f2b0b638932648d022b40d57c
Created June 28, 2016 16:21
Attempt to document Thread.app_lifetime
=head2 method app_lifetime
method app_lifetime(Thread:D:) returns Bool:D
Returns C<False> unless the named parameter C<:app_lifetime> is specifically set
to C<True> during object creation. If the method returns C<False> it means that the
the process will only terminate when the thread has finished while C<True> means that
the thread will be killed when the main thread of the process terminates.
my $t1 = Thread.new(code => { for 1..5 -> $v { say $v }});