AM Posted September 26, 2016 Share Posted September 26, 2016 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;PERMUTE-SYMMETRCIAL -> seq of any lengths;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; SUB (defun divide-seq-length (seq) (if (evenp (length seq)) (/ (length seq) 2) (/ (1- (length seq)) 2))) ;;; MAIN (defun permute-symmetrical (row &key (chance 0.5)) (let ((1st (loop repeat (divide-seq-length row) for cnt = 0 then (incf cnt) collect (nth cnt row))) (2nd (loop repeat (divide-seq-length row) for cnt = (- (length row) 1) then (decf cnt) collect (nth cnt row)))) (loop for i in 1st for j in 2nd when (prob? chance) collect j into 1st-bag and collect i into 2nd-bag else collect i into 1st-bag and collect j into 2nd-bag when (= (length 1st-bag) (divide-seq-length row)) do (return (if (evenp (length row)) (append 1st-bag (reverse 2nd-bag)) (append 1st-bag (list (nth (length 1st) row)) (reverse 2nd-bag))))))) ;;; EXAMPLE (pitch-list-plot (permute-symmetrical '(a4 bb4 ab4 b4 g4 c5 fs4 cs4 f4 d4 e4 eb4) ;zimmermann-row :chance 0.3)) opmo 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.