RosettaCodeData/Task/Averages-Mode/EchoLisp/averages-mode.l
2023-07-01 13:44:08 -04:00

16 lines
487 B
Common Lisp
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(define (modes L)
(define G (group* L)) ;; sorts and group equal items
(define cardmax (for/max [(g G)] (length g)))
(map first (filter (lambda(g) (= cardmax (length g))) G)))
(modes '( a b c a d e f))
(a)
(modes (iota 6))
(0 1 2 3 4 5)
(modes '(x))
(x)
(modes '(🎾 🏉 🎾 🎲 🎯 🎺 🎲 🎸 🎻 🏆 🏁 🎾 🎲 🎻 🏉 ))
(🎾 🎲)
(modes '())
😖 error: group : expected list : null 🔎 'modes'