Skip to content

Commit edbad25

Browse files
committed
Make examples compile
1 parent 61d6d56 commit edbad25

File tree

7 files changed

+111
-191
lines changed

7 files changed

+111
-191
lines changed

doc/Type/Int.pod6

Lines changed: 11 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
55
=SUBTITLE Integer (arbitrary-precision)
66
7-
class Int is Cool does Real {}
7+
=for code :skip-test
8+
class Int is Cool does Real { }
89
910
C<Int> objects store integral numbers of arbitrary size. C<Int>s are immutable.
1011
1112
There are two main syntax forms for C<Int> literals
1213
13-
123 # Int in decimal notation
14-
:16<BEEF> # Int in radix notations
14+
123; # Int in decimal notation
15+
:16<BEEF>; # Int in radix notations
1516
1617
For your convenience common radix forms come with a prefix shortcut.
1718
@@ -21,10 +22,10 @@ For your convenience common radix forms come with a prefix shortcut.
2122
All forms allow underscores between any two digits which can serve as visual
2223
separators, but don't carry any meaning:
2324
24-
5_00000 # five Lakhs
25-
500_000 # five hundred thousand
26-
0xBEEF_CAFE # a strange place
27-
:2<1010_1010> # 0d170
25+
5_00000; # five Lakhs
26+
500_000; # five hundred thousand
27+
0xBEEF_CAFE; # a strange place
28+
:2<1010_1010>; # 0d170
2829
2930
=head1 Methods
3031
@@ -35,31 +36,21 @@ Defined as:
3536
multi sub chr(Int:D ) returns Str:D
3637
multi method chr(Int:D:) returns Str:D
3738
38-
Usage:
39-
40-
chr INTEGER
41-
INTEGER.chr
42-
4339
Returns a one-character string, by interpreting the integer as a Unicode
4440
codepoint number and converting it to the corresponding character.
4541
4642
Example:
4743
48-
65.chr # returns "A"
49-
196.chr # returns "Ä"
44+
65.chr; # returns "A"
45+
196.chr; # returns "Ä"
5046
5147
=head2 routine expmod
5248
5349
Defined as:
5450
55-
multi sub expmod(Int:D: Int $y, Int $mod) returns Int:D
51+
multi sub expmod(Int $y, Int $mod) returns Int:D
5652
multi method expmod(Int:D: Int $y, Int $mod) returns Int:D
5753
58-
Usage:
59-
60-
expmod(INTEGER, POWER, MODULUS)
61-
INTEGER.expmod(POWER, MODULUS)
62-
6354
Returns the given C<Int> raised to the C<$y> power within modulus C<$mod>.
6455
6556
say expmod(4, 2, 5); # 1
@@ -71,10 +62,6 @@ Defined as:
7162
7263
method polymod(Int:D: +@mods)
7364
74-
Usage:
75-
76-
INTEGER.polymod(LIST)
77-
7865
Returns a sequence of mod results corresponding to the divisors in C<@mods>.
7966
The divisors are given from smallest "unit" to the largest
8067
(e.g. 60 seconds per minute, 60 minutes per hour) and the results
@@ -128,12 +115,6 @@ Defined as:
128115
multi sub is-prime (Int:D $number) returns Bool:D
129116
multi method is-prime (Int:D:) returns Bool:D
130117
131-
Usage:
132-
133-
is-prime INTEGER
134-
INTEGER.is-prime
135-
136-
137118
Returns C<True> if this C<Int> is known to be a prime, or is likely to be a
138119
prime based on a probabilistic Miller-Rabin test.
139120
@@ -149,11 +130,6 @@ Defined as:
149130
multi method lsb(Int:D:)
150131
multi sub lsb(Int:D)
151132
152-
Usage:
153-
154-
lsb INTEGER
155-
INTEGER.lsb
156-
157133
Returns L<Nil|/type/Nil> if the number is 0. Otherwise returns the zero-based
158134
index from the right of the least significant (rightmost) 1 in the binary
159135
representation of the number.
@@ -171,11 +147,6 @@ Defined as:
171147
multi method msb(Int:D:)
172148
multi sub msb(Int:D)
173149
174-
Usage:
175-
176-
msb INTEGER
177-
INTEGER.msb
178-
179150
Returns L<Nil|/type/Nil> if the number is 0. Otherwise returns the zero-based
180151
index from the right of the most significant (leftmost) 1 in the binary
181152
representation of the number.
@@ -193,11 +164,6 @@ Defined as:
193164
multi sub unival(Int:D) returns Numeric
194165
multi method unival(Int:D:) returns Numeric
195166
196-
Usage:
197-
198-
unival INTEGER
199-
INTEGER.unival
200-
201167
Returns the number represented by the Unicode codepoint with the given integer
202168
number, or L<NaN|/type/Num#NaN> if it does not represent a number.
203169

doc/Type/Map.pod6

Lines changed: 25 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
55
=SUBTITLE Immutable mapping from strings to values
66
7-
class Map does Associative is Iterable { }
7+
=for code :skip-test
8+
class Map does Associative is Iterable { }
89
910
A Map is an immutable mapping from string keys to values of arbitrary
1011
types. It serves as a base class for L<Hash>, which is mutable.
@@ -26,29 +27,26 @@ return them always in the same order when called on the same object.
2627
2728
Defined as:
2829
29-
proto method new(*@, *%) {*}
30+
proto method new(*@, *%)
3031
multi method new(*@args, *%pairs)
3132
32-
Usage:
33-
34-
Map.new(ARGS)
35-
3633
Creates a new Map from a list of alternating keys and values, with
3734
the same semantics as described for hash assigning in the L<Hash>
3835
documentation.
3936
37+
my %map = Map.new('a', 1, 'b', 2);
38+
4039
=head2 method elems
4140
4241
Defined as:
4342
44-
method elems(Map:D:) returns Int:D:
45-
46-
Usage:
47-
48-
MAP.elems
43+
method elems(Map:D:) returns Int:D
4944
5045
Returns the number of pairs stored in the Map.
5146
47+
my %map = Map.new('a', 1, 'b', 2);
48+
say %map.elems; # 2
49+
5250
=head2 method ACCEPTS
5351
5452
Defined as:
@@ -58,10 +56,6 @@ Defined as:
5856
multi method ACCEPTS(Map:D: Regex $topic)
5957
multi method ACCEPTS(Map:D: Any $topic)
6058
61-
Usage:
62-
63-
MAP.ACCEPTS(TOPIC)
64-
6559
Used in smart-matching if the right-hand side is an C<Map>.
6660
6761
If the topic is list-like (L<Positional>), returns True if
@@ -79,13 +73,16 @@ behavior is applied.
7973
To retrieve a value from the Map by key, use the C<{ }> postcircumfix
8074
operator:
8175
82-
my $value = $map{$key};
76+
my $map = Map.new('a', 1, 'b', 2);
77+
say $map{'a'}; # 1
8378
8479
To check whether a given key is stored in a Map, modify the access
8580
with the C<:exists> adverb:
8681
87-
if %h{$key}:exists {
88-
say "%h{} has key $key";
82+
my $map = Map.new('a', 1, 'b', 2);
83+
my $key = 'a';
84+
if $map{$key}:exists {
85+
say "$map{} has key $key";
8986
}
9087
9188
=head2 method keys
@@ -94,46 +91,39 @@ Defined as:
9491
9592
method keys(Map:D:) returns List:D
9693
97-
Usage:
98-
99-
MAP.keys
100-
10194
Returns a list of all keys in the Map.
10295
96+
my $m = Map.new('a' => (2, 3), 'b' => 17);
97+
say $m.keys; # (a b)
98+
10399
=head2 method values
104100
105101
Defined as:
106102
107103
method values(Map:D:) returns List:D
108104
109-
Usage:
110-
111-
MAP.values
112-
113105
Returns a list of all values in the Map.
114106
107+
my $m = Map.new('a' => (2, 3), 'b' => 17);
108+
say $m.values; # ((2 3) 17)
109+
115110
=head2 method pairs
116111
117112
Defined as:
118113
119114
method pairs(Map:D:) returns List:D
120115
121-
Usage:
122-
123-
MAP.pairs
124-
125116
Returns a list of all pairs in the Map.
126117
118+
my $m = Map.new('a' => (2, 3), 'b' => 17);
119+
say $m.pairs; # (a => (2 3) b => 17)
120+
127121
=head2 method antipairs
128122
129123
Defined as:
130124
131125
method antipairs(Map:D:) returns Seq:D
132126
133-
Usage:
134-
135-
MAP.antipairs
136-
137127
Returns all keys and their respective values as a L<Seq|/type/Seq> of C<Pair>s
138128
where the keys and values have been exchanged, i.e. the opposite of method
139129
L<pairs|#method_pairs>. Unlike the L<invert|#method_invert> method, there is
@@ -148,10 +138,6 @@ Defined as:
148138
149139
method invert(Map:D:) returns Seq:D
150140
151-
Usage:
152-
153-
MAP.invert
154-
155141
Returns all keys and their respective values as a L<Seq|/type/Seq> of C<Pair>s
156142
where the keys and values have been exchanged. The difference between C<invert>
157143
and L<antipairs|#method_antipairs> is that C<invert> expands list values into
@@ -166,24 +152,16 @@ Defined as:
166152
167153
method kv(Map:D:) returns List:D
168154
169-
Usage:
170-
171-
MAP.kv
172-
173155
Returns a list of keys and values interleaved.
174156
175-
Map.new('a', 1, 'b', 2).kv # a, 1, b, 2 OR b, 2, a, 1
157+
Map.new('a', 1, 'b', 2).kv # (a 1 b 2)
176158
177159
=head2 method Int
178160
179161
Defined as:
180162
181163
method Int(Map:D:) returns Int:D
182164
183-
Usage:
184-
185-
MAP.Int
186-
187165
Returns the number of pairs stored in the C<Map> (same as C<.elems>).
188166
189167
my $m = Map.new('a' => 2, 'b' => 17);
@@ -195,10 +173,6 @@ Defined as:
195173
196174
method Numeric(Map:D:) returns Int:D
197175
198-
Usage:
199-
200-
MAP.Numeric
201-
202176
Returns the number of pairs stored in the C<Map> (same as C<.elems>).
203177
204178
my $m = Map.new('a' => 2, 'b' => 17);
@@ -210,10 +184,6 @@ Defined as:
210184
211185
method Bool(Map:D:) returns Bool:D
212186
213-
Usage:
214-
215-
MAP.Bool
216-
217187
Returns C<True> if the invocant contains at least one key/value pair.
218188
219189
my $m = Map.new('a' => 2, 'b' => 17);
@@ -225,10 +195,6 @@ Defined as:
225195
226196
method Capture(Map:D:) returns Capture:D
227197
228-
Usage:
229-
230-
MAP.Capture
231-
232198
Returns a L<Capture|/type/Capture> where each key, if any, has been converted
233199
to a named argument with the same value as it had in the original C<Map>.
234200
The returned C<Capture> will not contain any positional arguments.

doc/Type/Mu.pod6

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
=SUBTITLE The root of the Perl 6 type hierarchy.
66
7-
class Mu {}
7+
class Mu { }
88
99
The root of the Perl 6 type hierarchy. For the origin of the name, see
1010
L<https://en.wikipedia.org/wiki/Mu_%28negative%29>. One can also say that
@@ -110,7 +110,7 @@ C<gist> is the method that L<say> calls implicitly, so C<say $something> and
110110
C<say $something.gist> generally produce the same output.
111111
112112
say Mu.gist; # (Mu)
113-
say Mu.new.gist; # Mu.new()
113+
say Mu.new.gist; # Mu.new
114114
115115
=head2 routine perl
116116
@@ -259,18 +259,19 @@ Returns an C<Int> representing the memory address of the object.
259259
260260
Returns the attached Pod value. For instance,
261261
262-
=for code
263-
sub cast(Spell $s)
264-
#= Initiate a specified spell normally
265-
#= (do not use for class 7 spells)
266-
{
267-
do-raw-magic($s);
268-
}
269-
say &cast.WHY;
262+
=for code :skip-test
263+
sub cast(Spell $s)
264+
#= Initiate a specified spell normally
265+
#= (do not use for class 7 spells)
266+
{
267+
do-raw-magic($s);
268+
}
269+
say &cast.WHY;
270270
271271
prints
272272
273-
Initiate a specified spell normally (do not use for class 7 spells)
273+
=for code :skip-test
274+
Initiate a specified spell normally (do not use for class 7 spells)
274275
275276
See the L<documentation specification|https://design.perl6.org/S26.html> for
276277
details about attaching Pod to variables, classes, functions, methods, etc.
@@ -290,7 +291,7 @@ See L<Exporting and Selective Importing Modules|/language/modules#Exporting_and_
290291
for more details.
291292
=head2 method return
292293
293-
method return();
294+
method return()
294295
295296
The method C<return> will stop execution of a subroutine or method, run all
296297
relevant L<phasers|/language/phasers#Block_Phasers> and provide invocant as a

0 commit comments

Comments
 (0)