/
Lipogram.pm6
83 lines (50 loc) · 1.84 KB
/
Lipogram.pm6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
use v6.c;
unit module Lingua::Lipogram:auth<github:sfischer13>:ver<0.1.0>;
our $VERSION = '0.1.0';
=begin pod
=head1 NAME
Lingua::Lipogram - Check whether a string is a lipogram.
=head1 SYNOPSIS
=begin code
use Lingua::Lipogram;
lipogram('The quick brown fox jumps over the lazy dog.', 's');
# OUTPUT: «False»
lipogram('The quick brown fox jumped over the lazy dog.', 's');
# OUTPUT: «True»
=end code
=head1 DESCRIPTION
Check whether a string or a file does not contain specific letters. All methods are case insensitive.
=head1 FUNCTIONS
=head2 lipogram
multi sub lipogram(Str $string, @letters --> Bool)
multi sub lipogram(IO::Path $path, Str $letters --> Bool)
multi sub lipogram(IO::Path $path, Range $letters --> Bool)
multi sub lipogram(Str $string, Str $letters --> Bool)
multi sub lipogram(Str $string, Range $letters --> Bool)
=end pod
multi lipogram(Str $string, @letters --> Bool) is export {
my $input = $string.fc;
my @tests = @letters.map(*.fc).grep(*.chars != 0);
return $input.index(none(@tests)).defined;
}
multi lipogram(IO::Path $path, Str $letters --> Bool) is export {
return lipogram($path.slurp, $letters.comb.unique);
}
multi lipogram(IO::Path $path, Range $letters --> Bool) is export {
return lipogram($path.slurp, $letters.map(*.Str));
}
multi lipogram(Str $string, Str $letters --> Bool) is export {
return lipogram($string, $letters.comb.unique);
}
multi lipogram(Str $string, Range $letters --> Bool) is export {
return lipogram($string, $letters.map(*.Str));
}
=begin pod
=head1 SEE ALSO
L<https://github.com/sfischer13/perl6-Lingua-Lipogram>
=head1 AUTHOR
Stefan Fischer <sfischer13@ymail.com>
=head1 COPYRIGHT AND LICENSE
Copyright (c) 2018 Stefan Fischer
This library is free software; you can redistribute it and/or modify it under the MIT License.
=end pod