-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
115 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,9 @@ say all-same("aaaaaa"); # "a" | |
say all-same("aaaaba"); # Nil | ||
say all-same(""); # Nil | ||
|
||
.say for paragraphs("a\n\nb"); # 0 => a2 => b | ||
.say for paragraphs($path.IO.lines); # … | ||
|
||
use String::Utils <before after>; # only import "before" and "after" | ||
|
||
=end code | ||
|
@@ -399,6 +402,23 @@ say all-same(""); # Nil | |
If the given string consists of a single character, returns that | ||
character. Else returns C<Nil>. | ||
|
||
=head2 paragraphs | ||
|
||
=begin code :lang<raku> | ||
|
||
.say for paragraphs($path.IO.lines); # … | ||
.say for paragraphs("a\n\nb"); # 0 => a2 => b | ||
.say for paragraphs("a\n\nb", 1); # 1 => a3 => b | ||
|
||
=end code | ||
|
||
Lazily produces a C<Seq> of C<Pairs> with paragraphs from a C<Seq> or | ||
string in which the key is the line number where the paragraph starts, | ||
and the value is the paragraph (without trailing newline). | ||
|
||
The optional second argument can be used to indicate the ordinal number | ||
of the first line in the string. | ||
|
||
=head1 AUTHOR | ||
|
||
Elizabeth Mattijsen <[email protected]> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters