I get an error when I try to find that letter is among alphabet.
onlineapp.d(13): Error: template
`std.algorithm.searching.findAmong` cannot deduce function from
argument types `!()(immutable(char), immutable(string))`,
candidates are:
/dlang/dmd/linux/bin64/../../src/phobos/std/algorithm/sear
On Monday, 5 July 2021 at 18:45:10 UTC, BoQsc wrote:
I get an error when I try to find that letter is among alphabet.
onlineapp.d(13): Error: template
`std.algorithm.searching.findAmong` cannot deduce function
from argument types `!()(immutable(char), immutable(string))`,
candidates are:
/dla
On Monday, 5 July 2021 at 18:53:27 UTC, jfondren wrote:
If you replace the findAmong call with
`[letter].findAmong(alphabet)`, this works.
Consider:
```d
import std;
void main() {
import std.ascii : alphabet = letters;
string wordExample = "Book.";
foreach (letter; wordExample)
On Monday, 5 July 2021 at 18:59:09 UTC, jfondren wrote:
On Monday, 5 July 2021 at 18:53:27 UTC, jfondren wrote:
If you replace the findAmong call with
`[letter].findAmong(alphabet)`, this works.
Consider:
```d
import std;
void main() {
import std.ascii : alphabet = letters;
string
On Monday, 5 July 2021 at 19:19:19 UTC, BoQsc wrote:
If I use `[letter].findAmong(alphabet)` in my code, it
considers a dot (.) punctuation character as a letter.
You can see it here:
https://run.dlang.io/is/YWmaXU
It returns a zero-length array that, because it's not null, is
true. That's wh
On Monday, 5 July 2021 at 19:25:23 UTC, jfondren wrote:
On Monday, 5 July 2021 at 19:19:19 UTC, BoQsc wrote:
If I use `[letter].findAmong(alphabet)` in my code, it
considers a dot (.) punctuation character as a letter.
You can see it here:
https://run.dlang.io/is/YWmaXU
It returns a zero-leng
On Monday, 5 July 2021 at 19:34:14 UTC, BoQsc wrote:
But I really don't like how it looks less readable and makes
less sense on first look.
`if (([letter].findAmong(alphabet)).length)`
I'd like to use some method on the `letter` instead of []
And `.length` does not make a lot of sense when rea
On Monday, 5 July 2021 at 19:48:13 UTC, jfondren wrote:
On Monday, 5 July 2021 at 19:34:14 UTC, BoQsc wrote:
But I really don't like how it looks less readable and makes
less sense on first look.
`if (([letter].findAmong(alphabet)).length)`
I'd like to use some method on the `letter` instead
On Tuesday, 6 July 2021 at 11:35:14 UTC, BoQsc wrote:
I tried out .canFind method, and to test it I removed the
letter 'o' from the Alphabet.
Weirdly enough .canFind method still found 'o' letter among the
Alphabet.
https://run.dlang.io/is/2Fvenf
Looks like it has something to do with the a
You can also do:
```d
import std;
void main()
{
// https://dlang.org/phobos/std_ascii.html#.lowercase
"Book.".filter!(c => lowercase.canFind(c))
.each!(c => writeln(c, " found"));
// Output:
// o found
// o found
// k found
}
```
On Tuesday, 6 July 2021 at 15:48:35 UTC, rassoc wrote:
You can also do:
```d
import std;
void main()
{
// https://dlang.org/phobos/std_ascii.html#.lowercase
"Book.".filter!(c => lowercase.canFind(c))
.each!(c => writeln(c, " found"));
// Output:
// o found
//
I think nested foreach loops are more readable.
```
import std;
void main()
{
alias alphabet = letters;
char[26] letters = ['a','b', 'c', 'd', 'e',
'f', 'g', 'h', 'i', 'j',
'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's',
On Wednesday, 7 July 2021 at 12:22:11 UTC, BoQsc wrote:
I think nested foreach loops are more readable.
```
import std;
void main()
{
alias alphabet = letters;
char[26] letters = ['a','b', 'c', 'd', 'e',
'f', 'g', 'h', 'i', 'j',
'k', 'l', '
13 matches
Mail list logo