Jump to content

Featured Replies

Posted
;;; alternative function for GEN-SYMMETRICAL: in combination 
;;; with FIND-UNIQUE => symmetries with unique items (except 
;;; what is generated by symmetry)


(defun gen-symmetrical* (n list)
  (let ((list (rnd-order list))
        (newlist (rest list))
        (center (car list)))   

    (if (> n (* 2 (length list)))
      'list-has-too-few-items
      (if (evenp n)
        (progn
          (setf list (rnd-unique (/ n 2) newlist))
          (append list (reverse list)))
        (progn 
          (setf list (rnd-unique (/ (1- n) 2) (rest newlist)))
          (append list (list center) (reverse list)))))))
  

(gen-symmetrical* 5 '(1 2 3 4 5 6 7 8))
(gen-symmetrical* 9 '(1 2 3 4 5 6 7 8))

(gen-symmetrical* 30 '(1 2 3 4 5 6 7 8))
=> list-has-too-few-items ; error-message

 

Create an account or sign in to comment


Copyright © 2014-2025 Opusmodus™ Ltd. All rights reserved.
Product features, specifications, system requirements and availability are subject to change without notice.
Opusmodus, the Opusmodus logo, and other Opusmodus trademarks are either registered trademarks or trademarks of Opusmodus Ltd.
All other trademarks contained herein are the property of their respective owners.

Powered by Invision Community

Important Information

Terms of Use Privacy Policy