8 ms·
The line below looks a lot more readable than the closure version. Enumerable.Range(1, 10).Select(i => i + 2).Sum()
by pixie_ 11y ago
The line below looks a lot more readable than the closure version.
Enumerable.Range(1, 10).Select(i => i + 2).Sum()
- huahaiy 11y agoIt depends on whom you ask. As a person who doesn't even know what language this is written in, I don't think it is readable at all. For example, this "Select(i => i + 2)" piece looks totally strange for me. What does it do? After learned Lisp, I feel there's too much syntax to learn for non-lisp languages. Every language introduces some idiosyncratic syntax. Life is too short, I just don't want to learn syntax that someone else invented to just be able to say "this is different".
- sheepmullet 11y agoIn clojure you would typically write it as: (->> (range 10) (map #(+ % 2)) (reduce +)) Which is just as readable as the .net equivalent.
- Scarblac 11y agoAnd I prefer sum(i + 2 for i in range(1, 10)) for readability. But we shouldn't judge languages on this sort of thing -- because then why don't we just write sum(range(3, 12)), or 63?
- pixie_ 11y agoIn both those cases you have to read it backwards to see what it does.