8.1. Übersicht

Das Auffinden von Allintervallreihen ist ein gutes Anwendungsbeispiel für eine Suche mit back propagation.

;; backward propagation

(ql:quickload "orm-utils")

(defun next-possible (intervals pitches &key (num 12))
    (loop for i from 1 to (1- num)
          if (not (or
                   (find i intervals)
                   (find (mod (+ (car pitches) i) num) pitches)))
            collect i))

(defun allintervall (anzahl-werte)
  (let ((solutions ()))
    (labels ((solve (intervals pitches pos &key num)
               (if (= pos (1- num))
                   (push (reverse intervals) solutions)
                   (dolist (x (next-possible intervals pitches :num num))
                     (solve
                      (cons x intervals)
                      (cons (mod (+ x (car pitches)) num) pitches)
                      (+ pos 1)
                      :num num)))))
      (solve () '(0) 0 :num anzahl-werte)
      (reverse solutions))))

(let ((num 6))
  (mapcar (lambda (x) (mapcar (lambda (x) (1+ (mod x num))) (ou:integrate (cons 0 x))))
          (allintervall num)))

(time (allintervall 6))

results matching ""

    No results matching ""