3 ms·
If the aim is golf, it's probably best to keep #" ". If the aim is accuracy, we might get better results by using #"[^\w]+". Though that does nasty things to wo
by wging 13y ago
If the aim is golf, it's probably best to keep #" ". If the aim is accuracy, we might get better results by using #"[^\w]+". Though that does nasty things to words like "it's".
Edit: Actually, we can also get rid of the 'reverse' by replacing (sort-by val) with (sort-by (comp - val)). Not going to be shorter in terms of character count, though we win on line count.
- JeanPierre 13y agosort-by takes an optional comparator, so doing (comp - val) is a bit unneeded. Just add in > as an argument to sort-by: (->> (string/split s #"\s+") frequencies (sort-by val >) (take 10)) Just mentioning it here because I find it vastly more readable than (comp - val).