Skip to content

Commit

Permalink
periodicity can use a list of lists also
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Edwards committed Nov 13, 2024
1 parent f73381f commit 0e3a606
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/utilities.lsp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
;;;
;;; Creation date: June 24th 2002
;;;
;;; $$ Last modified: 19:38:18 Wed Nov 13 2024 CET
;;; $$ Last modified: 19:46:21 Wed Nov 13 2024 CET
;;;
;;; ****
;;; Licence: Copyright (c) 2010 Michael Edwards
Expand Down Expand Up @@ -6784,6 +6784,9 @@ yes_foo, 1 2 3 4;
;;; Given a list of integers > 0, representing perhaps the number of items
;;; (e.g. pitches, rhythms etc.) in an arbitrary number of lists, calculate the
;;; cycle length before we repeat, i.e. start again at the beginning.
;;;
;;; NB for convenience the argument can be a list of lists, the lengths of which
;;; will then be used as above.
;;;
;;; ARGUMENTS
;;; a list of integers > 0
Expand Down Expand Up @@ -6813,6 +6816,8 @@ yes_foo, 1 2 3 4;
;;; SYNOPSIS
(defun periodicity (proportions)
;;; ****
(when (every #'listp proportions)
(setq proportions (loop for p in proportions collect (length p))))
(assert (and proportions (listp proportions)
(every #'integer>0 proportions)))
(let ((nds (remove-duplicates proportions
Expand Down
3 changes: 2 additions & 1 deletion tests/sc-test-suite.lsp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
;;;
;;; Creation date: 7th December 2011 (Edinburgh)
;;;
;;; $$ Last modified: 19:38:49 Wed Nov 13 2024 CET
;;; $$ Last modified: 19:45:19 Wed Nov 13 2024 CET
;;;
;;; SVN ID: $Id: sc-test-suite.lsp 6249 2017-06-07 16:05:15Z medward2 $
;;;
Expand Down Expand Up @@ -16427,6 +16427,7 @@
(and (= p period) (equalp l props)))))
(sc-test-check
(test-it '(1 2 5) 10 '(2 5))
(test-it '((1 2 3) (1 2 3 4 5) (a b c d e f)) 30 '(5 6))
(test-it '(1 2 3 4 5 6) 120 '(4 5 6))
(test-it '(1 2 3 4 5 6 20) 120 '(6 20))
(test-it '(1 2 3 4 5 6 16) 480 '(5 6 16)))))
Expand Down

0 comments on commit 0e3a606

Please sign in to comment.