r/Clojure • • Aug 10 '20

Counting elements

Post image
112 Upvotes

17 comments sorted by

View all comments

2

u/lenkite1 Aug 12 '20

I find the groupingBy identity and then reducing by counting quite easy and natural to read.

1

u/JavaSuck Aug 12 '20

That's because it's idiomatic Java 8, you'll find it in lots of places and Stack Overflow answers.

Before Java 5, for (Iterator<String> it = strings.iterator(); it.hashNext(); ) { String s = it.next; ... } was also quite easy and natural.