Inverted index: Difference between revisions
Content added Content deleted
(→{{header|D}}: less verbose; case-insensitive) |
(D entry 2nd try: identifiers capitalization according to the Dstyle, data file names closer to the Task name for simpler directory retrieval) |
||
Line 982: | Line 982: | ||
} |
} |
||
immutable |
immutable fileNames = ["inv1.txt", "inv2.txt", "inv3.txt"]; |
||
foreach ( |
foreach (fName; fileNames) |
||
parseFile( |
parseFile(fName); |
||
while (true) { |
while (true) { |
||
writef("\nEnter a word to search for: (q to quit): "); |
writef("\nEnter a word to search for: (q to quit): "); |
||
immutable w = readln().strip().toLower(); |
|||
if (w == "q") { |
if (w == "q") { |
||
writeln("quitting."); |
writeln("quitting."); |
||
Line 1,010: | Line 1,010: | ||
Enter a word to search for: (q to quit): is |
Enter a word to search for: (q to quit): is |
||
'is' found in " |
'is' found in "inv1.txt" "inv2.txt" "inv3.txt". |
||
Enter a word to search for: (q to quit): banana |
Enter a word to search for: (q to quit): banana |
||
'banana' found in " |
'banana' found in "inv3.txt". |
||
Enter a word to search for: (q to quit): it |
Enter a word to search for: (q to quit): it |
||
'it' found in " |
'it' found in "inv1.txt" "inv2.txt" "inv3.txt". |
||
Enter a word to search for: (q to quit): what |
Enter a word to search for: (q to quit): what |
||
'what' found in " |
'what' found in "inv1.txt" "inv2.txt". |
||
Enter a word to search for: (q to quit): q |
Enter a word to search for: (q to quit): q |