Jump to content

Featured Replies

Posted

the same idea with INSERT/REPLACE

 


(defun replace-on-event-number (omn-list &key position/list (type 'replace) (output nil))
  (progn 
    (setf omn-list (loop 
                     for i in (single-events omn-list)
                     for cnt = 0 then (incf cnt)
                     with position-list = (loop for x in position/list collect (car x))
                     with list = (loop for y in position/list collect (rest y))
                     with cnt2 = 0
                     
                     
                     when (= cnt (nth cnt2 position-list))
                     collect (cond ((equal type 'replace) 
                                    (if (listp (nth cnt2 list))
                                      (flatten (nth cnt2 list))
                                      (nth cnt2 list)))
                                   ((equal type 'add)
                                    (list i (nth cnt2 list))))
                     
                     else collect i
                     
                     when (and (= cnt  (nth cnt2 position-list))
                               (< cnt (car (last position-list))))
                     do (incf cnt2)))
    (if (equal output 'flatten)
      (flatten omn-list)
      omn-list)))
    
    

;;; EXAMPLES REPLACE

(replace-on-event-number '(q g4 -q q g4 g4 g4 -q g4 g4 g4 g4)
                           :position/list '((1 (q g5d5))
                                            (5 -q))
                           :type 'replace)

=> ((q g4 mf) (q g5d5) (q g4 mf) (q g4 mf) (q g4 mf) (-q) (q g4 mf) (q g4 mf) (q g4 mf) (q g4 mf))



(replace-on-event-number '(q g4 -q q g4 g4 g4 -q g4 g4 g4 g4)
                           :position/list '((1 (q g5d5))
                                            (5 -q))
                           :type 'replace
                           :output 'flatten)

=> (q g4 mf q g5d5 q g4 mf q g4 mf q g4 mf -q q g4 mf q g4 mf q g4 mf q g4 mf)


;;; EXAMPLES ADD

(replace-on-event-number '(q g4 -q q g4 g4 g4 -q g4 g4 g4 g4)
                           :position/list '((1 -e.)
                                            (5 -w))
                           :type 'add
                           :output nil)

=> ((q g4 mf) ((-q) (-e.)) (q g4 mf) (q g4 mf) (q g4 mf) ((-q) (-w)) (q g4 mf) (q g4 mf) (q g4 mf) (q g4 mf))



(replace-on-event-number '(q g4 -q q g4 g4 g4 -q g4 g4 g4 g4)
                           :position/list '((1 (w g6 ffff))
                                            (5 -w))
                           :type 'add
                           :output 'flatten)


=> (q g4 mf -q w g6 ffff q g4 mf q g4 mf q g4 mf -q -w q g4 mf q g4 mf q g4 mf q g4 mf)

;;;;

 

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