Created
June 1, 2021 09:50
-
-
Save lukego/2bdacbaea35211f1c4fde99c74268ebf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun same (key-fn list &key (test #'eql)) | |
"True if KEY-FN returns the same value for every element of LIST. | |
Example: (same #'length '((a b c) (d e f) #(1 2 3))) => T" | |
(or (null list) | |
(loop with v = (funcall key-fn (first list)) | |
for x in (rest list) | |
always (funcall test v (funcall key-fn x))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment