3 ms·
Does it handle multiple files, and stdin? Anyway, destroying Haskell with 100 lines of C :-) https://raw.githubusercontent.com/gdevic/minix1/master/commands/
by jacobush 7y ago
Does it handle multiple files, and stdin?
Anyway, destroying Haskell with 100 lines of C :-)
https://raw.githubusercontent.com/gdevic/minix1/master/commands/wc.c https://raw.githubusercontent.com/gdevic/minix1/master/comma...
- jstimpfle 7y agoDo you get a speed-up if you use getc_unlocked() instead of getc()? And if you write your own isspace()? As far as I know, isspace() is locale sensitive.
- sauerbraten 7y agoisspace is defined as a macro at the top of the file, and it's definitely not locale sensitive ;)
- hrgiger 7y agoI see and raise, to one line: https://www.ioccc.org/2019/burton/prog.c https://www.ioccc.org/2019/burton/prog.c It is the Burton entry from The International Obfuscated C Code Contest, but seems like only handling ascii https://www.ioccc.org/years-spoiler.html https://www.ioccc.org/years-spoiler.html Limits: "Requires the C locale and ASCII character set. Input should be less than ten million octets to avoid this problem." https://www.ioccc.org/2019/burton/hint.html https://www.ioccc.org/2019/burton/hint.html
- ulucs 7y agoIsn't 100 lines too much for a simple utility like wc? I get that it has many edge cases to cover, but edge cases usually require some different handling when you run into them anyway. I'd rather use my one-liner (including calculation in a single pass, and even parallel processing!): wc:{sum (({1};ceiling 0.5*sum differ " "=;{1+count x})@\:) peach read0 x}