one problem with this relevance, is that it should be calculating the number of lines of the file for every line of the file times 2, so this is very inefficient, especially with files with large number of lines.
I made a file with 10000 lines:
Q: lines (integers in (number of lines of files "C:\Windows\Temp\linesoffile.txt" - 5,number of lines of files "C:\Windows\Temp\linesoffile.txt")) of files "C:\Windows\Temp\linesoffile.txt"
A: 9995
A: 9996
A: 9997
A: 9998
A: 9999
A: 10000
T: 2021.247 ms
Your relevance took 2 seconds to return, which is not very good performance. The relevance below was almost 4 times faster, and this problem increases exponentially with the number of lines of the file.
If you want to be efficient, it is much harder:
(item 1 of /* -> This "it" refers to the last 100 lines of the file -> */ it) whose( /* -> remove empty lines, which is why this relevance can return less than 100 lines per file -> */ it as trimmed string != "") of ( /* -> this is the number of lines of the file from the previous statement -> */ item 1 of it, (lines of /* -> the file object -> */ item 0 of it) ) /* -> This whose statement is responsible for filtering for only the last 100 lines of the file -> */ whose ( (line number of /* -> lines of the file -> */ item 1 of it) > ( /* -> number of lines of the file -> */ item 0 of it - 100 /* <- This is the number of lines to return, which is subtracted from the total # of lines <- */ ) ) of ( /* -> the parent file object itself -> */ it, number of lines of it) of files ...
Let me break this down with an example file with 10 lines:
Q: (it, number of lines of it) of files "C:\Windows\Temp\linesoffile.txt"
A: "linesoffile.txt" "" "" "" "", 10
T: 1.164 ms
…
This is the number of lines in the file with the contents of each line of the file:
Q: ( item 1 of it, (lines of item 0 of it) ) of (it, number of lines of it) of files "C:\Windows\Temp\linesoffile.txt"
A: 10, Line 1
A: 10, Line 2
A: 10, Line 3
A: 10, Line 4
A: 10, Line 5
A: 10, Line 6
A: 10, Line 7
A: 10, Line 8
A: 10, Line 9
A: 10, Line 10
T: 1.060 ms
…
This added whose statement filters down to only the lines that have a line number greater than the total number of lines minus the number of lines to return: (this also works if the total lines to return is greater than the number of lines in the file)
Q: ( item 1 of it, (lines of item 0 of it) ) whose ( (line number of item 1 of it) > ( item 0 of it - 5 /* <- This is the number of lines to return, which is subtracted from the total # of lines <- */ ) ) of (it, number of lines of it) of files "C:\Windows\Temp\linesoffile.txt"
A: 10, Line 6
A: 10, Line 7
A: 10, Line 8
A: 10, Line 9
A: 10, Line 10
T: 1.139 ms
…
This will give only the lines of the file:
Q: items 1 of ( item 1 of it, (lines of item 0 of it) ) whose ( (line number of item 1 of it) > ( item 0 of it - 5 /* <- This is the number of lines to return, which is subtracted from the total # of lines <- */ ) ) of (it, number of lines of it) of files "C:\Windows\Temp\linesoffile.txt"
A: Line 6
A: Line 7
A: Line 8
A: Line 9
A: Line 10
T: 1.050 ms
This relevance only calculates the total number of lines once, and only reads the file lines once, though there might be other improvements that could be made to this relevance.