On Tuesday, 3 October 2017 at 19:25:56 UTC, Ali Çehreli wrote:
Found on Reddit:


https://www.reddit.com/r/programming/comments/740617/the_expressive_c17_coding_challenge/

How would you do it in D?

Ali

P.S. You can ignore the following note from the challenge text; I don't think it applies to D. Honestly, I don't think it matters for C++17 either. :)

"You can assume input files won't be super large and can fit fully into memory."

https://gist.github.com/Biotronic/0bc6048b880d67bfdca970453cc47cf9

I opted for writing to stdout instead, because 1) it's easier, x) it's less code, and b) it's more flexible.

The memory limitations certainly do apply - readText would fail upon reading humongous files, and for 32-bit programs the resulting string wouldn't be able to hold enough data. Since the code uses ranges though, a simple replacement of readText with an mmapped equivalent should enable humongous file support with no other code change required.

--
  Biotronic

Reply via email to