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/searching.d(2694):
`findAmong(alias pred = "a == b", InputRange, ForwardRange)(InputRange seq,
ForwardRange choices)`
with `pred = "a == b",
InputRange = immutable(char),
ForwardRange = string`
must satisfy the following constraint:
` isInputRange!InputRange`
This is the code: You can run it at:
https://run.dlang.io/is/5cvuUZ
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', 't',
'u', 'v', 'w', 'x', 'y', 'z'];
string wordExample = "Book.";
foreach (letter; wordExample){
if (letter.findAmong(alphabet)){
write("found");
}
write(letter);
}
}