Re:Destroying C with 20 lines of Haskell: wc
by hrgiger on Tuesday February 04, 2020 @08:44AM
(#22235408)
I see and raise, to one line:
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
Limits:
"Requires the C locale and ASCII character set. Input should be less than ten million octets to avoid this problem."
Re:Destroying C with 20 lines of Haskell: wc
by ulucs on Tuesday February 04, 2020 @09:03AM
(#22235577)
Isn'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}
Re:Destroying C with 20 lines of Haskell: wc
by jstimpfle on Tuesday February 04, 2020 @08:40AM
(#22235359)
Do 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.
Re:Destroying C with 20 lines of Haskell: wc
by sauerbraten on Tuesday February 04, 2020 @09:04AM
(#22235588)
isspace is defined as a macro at the top of the file, and it's definitely not locale sensitive ;)
Anyway, destroying Haskell with 100 lines of C :-)
https://raw.githubusercontent.com/gdevic/minix1/master/comma...