3 ms·
>>> foldMap countChar "one two\nthree" Counts {charCount = 13, wordCount = Flux NotSpace 3 NotSpace, lineCount = 1}”* That lineCount = 1 surprised me, but
by Someone 7y ago
>>> foldMap countChar "one two\nthree"
Counts {charCount = 13, wordCount = Flux NotSpace 3
NotSpace, lineCount = 1}”*
That lineCount = 1 surprised me, but testing on a Mac showed it to be ‘correct’. At least there, you can have a non-empty file that has zero lines.
- boomlinde 7y agoIn POSIX, a text file is a file consisting of zero or more lines. A line is a sequence of non-null characters, shorter than a system defined maximum and terminated by a line feed character. So a file that completely matches the string "one two\nthree" is by POSIX standards not a text file. Of course, wc doesn't necessarily operate on text files so you could interpret the result as a "complete POSIX line count".