Posted November 17, 2024Nov 17 Hi, Is it possible to write a function which gives the following result: ((1)(1 2 2)(1 2 2 3 3 3)(1 2 2 3 3 3 4 4 4 4)(1 2 2 3 3 3 4 4 4 4 5 5 5 5 5))etc. Thanks for any suggestions!
November 17, 2024Nov 17 (defun generate (n) "Generate a nested list where each sublist expands with numbers repeating themselves." (loop for i from 1 to n collect (loop for j from 1 to i append (make-list j :initial-element j))))
Create an account or sign in to comment