diff options
author | rekado <rekado@elephly.net> | 2016-10-01 18:10:29 +0200 |
---|---|---|
committer | rekado <rekado@elephly.net> | 2016-10-01 18:33:33 +0200 |
commit | 0e04741d8fb5fb53b6ec3d8444d739b0cf6eeb36 (patch) | |
tree | 4090f1286112dc90d4739ad93f12616f63d9c7c5 | |
parent | a6fedd3ea76b4bad1c36f2bc7c839598079d1f10 (diff) |
Prevent infinite loop when invalid root note is provided.
-rw-r--r-- | scales/utils.scm | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/scales/utils.scm b/scales/utils.scm index 5c488a3..31d1c12 100644 --- a/scales/utils.scm +++ b/scales/utils.scm @@ -19,17 +19,28 @@ #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) #:use-module (srfi srfi-26) - #:export (all-notes-from + #:export (leave + all-notes-from make-scale-note scale-note-note scale-note-offset)) +(define (leave . messages) + (apply format (current-error-port) messages) + (exit 1)) + + +(define valid-notes + '(a ais b c cis d dis e f fis g gis)) + (define all-notes - (circular-list 'a 'ais 'b 'c 'cis 'd 'dis 'e 'f 'fis 'g 'gis)) + (apply circular-list valid-notes)) (define (all-notes-from root) + (when (not (member root valid-notes)) + (leave "Invalid root note. Valid notes are:\n\n~{ ~s\n~}\n" valid-notes)) (find-tail (cut eqv? root <>) all-notes)) |