Skip to content

Commit f6fdcdd

Browse files
committed
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
1 parent e61284a commit f6fdcdd

File tree

5 files changed

+70
-173
lines changed

5 files changed

+70
-173
lines changed

htmlify.p6

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ multi write-type-source($doc) {
196196

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

199+
if !$doc.pod-is-complete {
200+
$pod = pod-with-title("$doc.subkinds() $podname", $pod[1..*])
201+
}
202+
199203
if $type {
200204
$pod.content.push: Pod::Block::Named.new(
201205
name => 'Image',

lib/Type/Set.pod renamed to lib/Language/Sets_Bags_and_Mixes.pod

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,79 @@
11
=begin pod
22
3-
=TITLE class Set
3+
=TITLE Sets, Bags, and Mixes
4+
5+
=DESCRIPTION Unique collections and weighted lists in Perl 6
6+
7+
An introduction of what I'm going to talk about.
8+
9+
=head1 class Set
410
511
class Set does Setty { }
612
713
An immutable set of unique values or objects. These values can be
814
accessed via the C<{ }> postcircumfix, and always have a value of either
915
C<True> or C<False>. For a mutable set, see L<SetHash>.
1016
11-
=head1 Methods
17+
=head2 Methods
1218
13-
=head2 total
19+
=head3 total
1420
1521
method total(Set:D:)
1622
1723
Equivalent to C<elems>, added for consistency with the L<Bag> and L<Mix>
1824
types
1925
20-
=head1 Operators
21-
22-
All of the following infix operators will take most types as their
23-
arguments and coerce them to C<Set>s. In some cases, if a type of an
24-
argument is a L<Bag>, the infix operator will behave in a different but
25-
analogous way to the one described here.
26+
=head2 Operators
2627
27-
=head2 sub set
28+
=head3 sub set
2829
2930
sub set(*@args --> Set)
3031
3132
Creates a C<Set> from the given C<@args>
3233
34+
=head1 class Bag
35+
36+
class Bag does Baggy { }
37+
38+
An immutable collection of weighted values. These weights are always
39+
integers, and can be accessed with the C<{ }> postcircumfix. For a
40+
mutable collection of weighted values, see L<BagHash>.
41+
42+
bag('a', 'b', 'c', 'a', 'd', 'a')<a> === 3
43+
44+
=head2 Operators
45+
46+
=head3 sub bag
47+
48+
sub bag(*@args --> Bag)
49+
50+
Creates a new C<Bag> from C<@args>.
51+
52+
=head1 class Mix
53+
54+
class Mix does Mixy { }
55+
56+
An immutable collection of weighted values. The weights are accessable
57+
via the C<{ }> postcircumfix. For a mutable collection, see L<MixHash>.
58+
59+
# TODO: More useful example
60+
{a => 1.3, b => 4.8, c => 8}.Mix<b> == 4.8 # True
61+
62+
=head2 Operators
63+
64+
=head3 sub mix
65+
66+
sub mix(*@args --> Mix)
67+
68+
Creates a new C<Mix> from C<@args>.
69+
70+
=head1 Set/Bag Operators
71+
72+
All of the following infix operators will take most types as their
73+
arguments and coerce them to C<Set>s. In some cases, if a type of an
74+
argument is a L<Bag>, the infix operator will behave in a different but
75+
analogous way to the one described here.
76+
3377
=head2 infix (elem)
3478
3579
multi sub infix:<(elem)>($a, Any $b --> Bool)

lib/Pod/Convenience.pm6

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,23 @@ sub pod-with-title($title, *@blocks) is export {
5959
Pod::Block::Named.new(
6060
name => "pod",
6161
content => [
62-
Pod::Block::Named.new(
63-
name => "TITLE",
64-
content => Array.new(
65-
Pod::Block::Para.new(
66-
content => [$title],
67-
)
68-
)
69-
),
62+
pod-title($title),
7063
@blocks.flat,
7164
]
7265
);
7366
}
7467

68+
sub pod-title($title) is export {
69+
Pod::Block::Named.new(
70+
name => "TITLE",
71+
content => Array.new(
72+
Pod::Block::Para.new(
73+
content => [$title],
74+
)
75+
)
76+
)
77+
}
78+
7579
sub pod-block(*@content) is export {
7680
Pod::Block::Para.new(:@content);
7781
}

lib/Type/Bag.pod

Lines changed: 0 additions & 134 deletions
This file was deleted.

lib/Type/Mix.pod

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)