2 ms·
Take a look at factor: http://factorcode.org/ http://factorcode.org/ Your example would be written as: "C:/tmp/adinst.log" utf16 file-lines [ "SEARCH" swap
by bjourne 12y ago
Take a look at factor: http://factorcode.org/ http://factorcode.org/ Your example would be written as:
"C:/tmp/adinst.log" utf16 file-lines [ "SEARCH" swap start ] filter members length
File is opened into a sequence of lines, then the sequence is filtered so that only lines containing "SEARCH" remain, then members removes duplicates, then length gets the number of elements left in the sequence. In the shell, "|" is the function composition operator, in haskell it's "." In Factor, any whitespace is function composition!