Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Introduce Sets_Bags_and_Mixes.pod
This includes the definitions of Set, Bag, and Mix, as well as the
Set/Bag operators. The pages for Set, Bag and Mix are automatically
generated from the documentation
  • Loading branch information
Mouq committed Jun 17, 2014
1 parent e61284a commit f6fdcdd
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 173 deletions.
4 changes: 4 additions & 0 deletions htmlify.p6
Expand Up @@ -196,6 +196,10 @@ multi write-type-source($doc) {

say "Writing $what document for $podname ...";

if !$doc.pod-is-complete {
$pod = pod-with-title("$doc.subkinds() $podname", $pod[1..*])
}

if $type {
$pod.content.push: Pod::Block::Named.new(
name => 'Image',
Expand Down
64 changes: 54 additions & 10 deletions lib/Type/Set.pod → lib/Language/Sets_Bags_and_Mixes.pod
@@ -1,35 +1,79 @@
=begin pod
=TITLE class Set
=TITLE Sets, Bags, and Mixes
=DESCRIPTION Unique collections and weighted lists in Perl 6
An introduction of what I'm going to talk about.
=head1 class Set
class Set does Setty { }
An immutable set of unique values or objects. These values can be
accessed via the C<{ }> postcircumfix, and always have a value of either
C<True> or C<False>. For a mutable set, see L<SetHash>.
=head1 Methods
=head2 Methods
=head2 total
=head3 total
method total(Set:D:)
Equivalent to C<elems>, added for consistency with the L<Bag> and L<Mix>
types
=head1 Operators
All of the following infix operators will take most types as their
arguments and coerce them to C<Set>s. In some cases, if a type of an
argument is a L<Bag>, the infix operator will behave in a different but
analogous way to the one described here.
=head2 Operators
=head2 sub set
=head3 sub set
sub set(*@args --> Set)
Creates a C<Set> from the given C<@args>
=head1 class Bag
class Bag does Baggy { }
An immutable collection of weighted values. These weights are always
integers, and can be accessed with the C<{ }> postcircumfix. For a
mutable collection of weighted values, see L<BagHash>.
bag('a', 'b', 'c', 'a', 'd', 'a')<a> === 3
=head2 Operators
=head3 sub bag
sub bag(*@args --> Bag)
Creates a new C<Bag> from C<@args>.
=head1 class Mix
class Mix does Mixy { }
An immutable collection of weighted values. The weights are accessable
via the C<{ }> postcircumfix. For a mutable collection, see L<MixHash>.
# TODO: More useful example
{a => 1.3, b => 4.8, c => 8}.Mix<b> == 4.8 # True
=head2 Operators
=head3 sub mix
sub mix(*@args --> Mix)
Creates a new C<Mix> from C<@args>.
=head1 Set/Bag Operators
All of the following infix operators will take most types as their
arguments and coerce them to C<Set>s. In some cases, if a type of an
argument is a L<Bag>, the infix operator will behave in a different but
analogous way to the one described here.
=head2 infix (elem)
multi sub infix:<(elem)>($a, Any $b --> Bool)
Expand Down
20 changes: 12 additions & 8 deletions lib/Pod/Convenience.pm6
Expand Up @@ -59,19 +59,23 @@ sub pod-with-title($title, *@blocks) is export {
Pod::Block::Named.new(
name => "pod",
content => [
Pod::Block::Named.new(
name => "TITLE",
content => Array.new(
Pod::Block::Para.new(
content => [$title],
)
)
),
pod-title($title),
@blocks.flat,
]
);
}

sub pod-title($title) is export {
Pod::Block::Named.new(
name => "TITLE",
content => Array.new(
Pod::Block::Para.new(
content => [$title],
)
)
)
}

sub pod-block(*@content) is export {
Pod::Block::Para.new(:@content);
}
Expand Down
134 changes: 0 additions & 134 deletions lib/Type/Bag.pod

This file was deleted.

21 changes: 0 additions & 21 deletions lib/Type/Mix.pod

This file was deleted.

0 comments on commit f6fdcdd

Please sign in to comment.