Created
February 19, 2024 21:13
-
-
Save selwynsimsek/79b214fe608d28362b640224a65ac87e to your computer and use it in GitHub Desktop.
This file contains hidden or 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 generate-tuples (n k) | |
(cond ((zerop n) `()) | |
((= n 1) `(,(list k))) | |
((zerop k) `(,(make-list n :initial-element 0))) | |
(t (loop for i from 0 upto k appending | |
(mapcar (lambda (a) (cons i a)) (generate-tuples (1- n) (- k i))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment