Jump to content

Featured Replies

Posted

 

;;;;small function -> create symmetrical lists (palindrom) with markov (for generating half-seq)

(setf transition
      '((1 (4 1) (5 1) (-6 2))
        (2 (5 2) (4 1))
        (3 (4 1))
        (4 (5 1) (2 1))
        (5 (1 3) (-6 2) (4 1))
        (-6 (4 1) (3 2))
        (7 (1 1) (-6 1))))

;;;FUNCTION

(defun gen-sym-markov (&key seq-length transition-matrix) 
 (let ((vals 0))
   ;falls seq-length = liste, werden positive werte gezählt und neu
   ;seq-length (= angepasst, formatunabhängig)
   (if (listp seq-length)
     (setq seq-length (car (last (loop for i in seq-length
                                   with cnt = 0
                                   when (> i 0)
                                   collect (incf cnt))))))
   ;entscheindung grad/ungrad
   (if (evenp seq-length)
     (progn 
       (setq vals (gen-markov-from-transitions transition-matrix :size (/ seq-length 2) :start (rnd-pick (flatten (filter-first 1 transition-matrix)))))
       (append vals (reverse vals)))

     (progn 
       (setq vals (gen-markov-from-transitions transition-matrix :size (/ (- seq-length 1) 2) :start (rnd-pick (flatten (filter-first 1 transition-matrix)))))
       (append vals (list (rnd-pick (flatten (filter-first 1 transition-matrix)))) (reverse vals))))))


;;;;EXAMPLE

(gen-sym-markov :seq-length 8 :transition-matrix transition)

 

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