Guest User

Untitled

a guest
Nov 16th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. (my-partition-randomly '(a b c d e f g h i j k l) 4)
  2.  
  3. '((a b c) (d) (e f g h) (i j k) (l))
  4.  
  5. (defun my-partition-randomly (list max-length) ""
  6. (let ((result '()))
  7. (while list
  8. (push (seq-take-while (lambda (x) x)
  9. (map 'list
  10. (lambda (x) (pop list))
  11. (number-sequence 1 (+ 1 (random max-length)))))
  12. result))
  13. (reverse result)))
Add Comment
Please, Sign In to add comment