"Finding most frequent element in a list"
A question on Stackoverflow and a brief search led me to some thoughts I want to register to document my learning experience.
I've been searching for a while for a function that does this in (Common) Lisp. Does one already exist, or do I need to code it on my own? To be more specific, I'm looking for a function that if I fed it in something like
'(1 2 4 1)
, it would return1
?
First of all, the request specifics are incomplete: what should the function return if there's more than one element that occur most frequently? What is the notion of sameness among the elements of the list?
As a beginner, I often find myself looking for idiomatic ways to do things: reusing code in a package is apparently the way to go, but I haven't found a clear path yet for such researchs: I usually look for something in Quicklisp package collection, then on github and the Clwiki. I suspect that, at least for these simple functions, CL makes it so easy to roll your own version that everybody end up writing a homemade solution.