Skip to content

Commit bc7a753

Browse files
committed
whitespace
1 parent 0c0dc4c commit bc7a753

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

doc/Language/101-basics.pod6

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
=begin pod :tag<tutorial> :page-order<A00>
22
3-
=TITLE Perl 6 Example P6-101
3+
=TITLE Perl 6 Example P6-101
44
5-
=SUBTITLE A basic introductory example of a Perl 6 program
5+
=SUBTITLE A basic introductory example of a Perl 6 program
66
77
Perl originated as a programming language intended to gather and summarize
8-
information from text files. It's still strong in text processing, but Perl 5
9-
is also a powerful general-purpose programming language. Perl 6 is even better.
8+
information from text files. It's still strong in text processing, but Perl 5
9+
is also a powerful general-purpose programming language. Perl 6 is even better.
1010
1111
Suppose that you host a table tennis tournament. The referees tell you the
1212
results of each game in the format C<Player1 Player2 | 3:2>, which means
@@ -27,7 +27,7 @@ The input data (stored in a file called "scores.txt") looks like this:
2727
The first line is the list of players. Every subsequent line records a result
2828
of a match.
2929
30-
Here's one way to solve that problem in Perl 6:
30+
Here's one way to solve that problem in Perl 6:
3131
3232
=begin code
3333
@@ -75,13 +75,13 @@ This produces the output:
7575
7676
=head3 X<C<v6>>
7777
78-
Every Perl 6 program should begin with C<use v6;>. This line tells the compiler
78+
Every Perl 6 program should begin with C<use v6;>. This line tells the compiler
7979
which version of Perl the program expects. Should you accidentally run the file
80-
with Perl 5, you'll get a helpful error message.
80+
with Perl 5, you'll get a helpful error message.
8181
8282
=head3 X<C<statement>>
8383
84-
A Perl 6 program consists of zero or more statements. A I<statement> ends with
84+
A Perl 6 program consists of zero or more statements. A I<statement> ends with
8585
a semicolon or a curly bracket at the end of a line:
8686
8787
=begin code
@@ -142,14 +142,14 @@ the argument provided to C<open>.
142142
=head3 X<C<array>>, X<C<method>> and X<C<invocant>>
143143
144144
The right-hand side calls a I<method> --a named group of behavior-- named C<get>
145-
on the file handle stored in C<$file>. The C<get> method reads and returns
145+
on the file handle stored in C<$file>. The C<get> method reads and returns
146146
one line from the file, removing the line ending. If you print the contents of C<$file>
147-
after calling C<get>, you will see that the first line is no longer in there. C<words> is also a method,
148-
called on the string returned from C<get>. C<words> decomposes its
147+
after calling C<get>, you will see that the first line is no longer in there. C<words> is also a method,
148+
called on the string returned from C<get>. C<words> decomposes its
149149
I<invocant>--the string on which it operates--into a list of words, which
150150
here means strings separated by whitespace.
151-
It turns the single string C<'Beth Ana Charlie Dave'> into the list of
152-
strings C<'Beth', 'Ana', 'Charlie', 'Dave'>.
151+
It turns the single string C<'Beth Ana Charlie Dave'> into the list of
152+
strings C<'Beth', 'Ana', 'Charlie', 'Dave'>.
153153
154154
Finally, this list gets
155155
stored in the array C<@names>. The C<@> sigil marks the declared variable as
@@ -168,8 +168,8 @@ These two lines of code declare two hashes. The C<%> sigil marks each
168168
variable as a C<Hash>. A C<Hash> is an unordered collection of key-value
169169
pairs. Other programming languages call that a I<hash table>,
170170
I<dictionary>, or I<map>. You can query a hash table for the value that
171-
corresponds to a certain C<$key> with C<%hash{$key}>N<Unlike Perl 5, in
172-
Perl 6 the sigil does not change when accessing an array or hash with
171+
corresponds to a certain C<$key> with C<%hash{$key}>N<Unlike Perl 5, in
172+
Perl 6 the sigil does not change when accessing an array or hash with
173173
C<[ ]> or C<{ }>. This is called X<I<sigil invariance>>.>.
174174
175175
In the score counting program, C<%matches> stores the number of matches each
@@ -319,7 +319,7 @@ are passed in through the I<topic variable> C<$_>.
319319
320320
You have seen blocks before: both the C<for> loop C<< -> $line { ... } >> and
321321
the C<if> statement worked on blocks. A block is a self-contained piece of
322-
Perl 6 code with an optional signature (the C<< -> $line >> part). See
322+
Perl 6 code with an optional signature (the C<< -> $line >> part). See
323323
A<sec:signatures> for more information.
324324
325325
The simplest way to sort the players by score would be C<@names.sort({
@@ -332,7 +332,7 @@ tournament.
332332
333333
When two array items have the same value, C<sort> leaves them in the same order
334334
as it found them. Computer scientists call this a I<stable sort>. The program
335-
takes advantage of this property of Perl 6's C<sort> to achieve the goal by
335+
takes advantage of this property of Perl 6's C<sort> to achieve the goal by
336336
sorting twice: first by the number of sets won (the secondary criterion), then
337337
by the number of matches won.
338338
@@ -382,7 +382,7 @@ not interpolate:
382382
383383
=end code
384384
385-
Double quoted strings in Perl 6 can interpolate variables with the C<$>
385+
Double quoted strings in Perl 6 can interpolate variables with the C<$>
386386
sigil as well as blocks of code in curly braces. Since any arbitrary
387387
Perl code can appear within curly braces, C<Array>s and C<Hash>es may be
388388
interpolated by placing them within curly braces.
@@ -394,12 +394,12 @@ item. Hashes within curly braces are interpolated as a series of
394394
lines. Each line will contain a key, followed by a tab character, then
395395
the value associated with that key, and finally a newline.
396396
397-
Let's see an example of this now.
397+
Let's see an example of this now.
398398
399399
In this example, you will see some special syntax that makes it easier
400400
to make a list of strings. This is the C<< <...> >> L<quote-words|https://docs.perl6.org/language/operators#index-entry-qw-quote-words-quote-words> construct.
401401
When you put words in between the < and > they are all assumed to be strings,
402-
so you do not need to wrap them each in double quotes C<< "..." >>.
402+
so you do not need to wrap them each in double quotes C<< "..." >>.
403403
404404
=begin code
405405
@@ -474,7 +474,7 @@ B<2.> Instead of deleting the redundant C<@names> variable, you can also use it
474474
player appears that wasn't mentioned in the first line, for example due to a
475475
typo. How would you modify your program to achieve that?
476476
477-
Hint: Try using L<membership operators|https://docs.perl6.org/routine/(elem)>.
477+
Hint: Try using L<membership operators|https://docs.perl6.org/routine/(elem)>.
478478
479479
B<Answer:> Change C<@names> to C<@valid-players>. When looping through the lines of
480480
the file, check to see that C<$p1> and C<$p2> are in C<@valid-players>. Note that

0 commit comments

Comments
 (0)