4 ms·
Here's my stab at it: https://gist.github.com/976020 https://gist.github.com/976020 I think the biggest advantage of Clojure over Java for code like this is h
by mkoch 15y ago
Here's my stab at it:
https://gist.github.com/976020 https://gist.github.com/976020
I think the biggest advantage of Clojure over Java for code like this is how easy it is to use lazy sequences and higher-order functions.
In this example there isn't much to be gained in the error-handling and logging; however, if there were other similar functions it might be easier to factor out some of the common patterns in Clojure, since functions like the predicate to ignore a line can be easily passed through. Or, for example, you could write a custom version of with-open or line-seq to do the desired logging behind-the-scenes.
- efsavage 15y agoThanks, that's a very helpful illustration and gives a good idea of where it ends up. It's actually more readable than most of the other examples I've seen which I think err on the side of being too simple or too clever.