]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 4501/1: Add music-type-predicate function
authorDavid Kastrup <dak@gnu.org>
Sun, 12 Jul 2015 10:02:44 +0000 (12:02 +0200)
committerDavid Kastrup <dak@gnu.org>
Tue, 21 Jul 2015 06:14:23 +0000 (08:14 +0200)
This creates a predicate function checking for a set of types.

scm/music-functions.scm

index a952a8284649d78dfa71e19522111d55e2139b51..132f2f236947c4b9395a37df53255556d7b0ed33 100644 (file)
   "Does @code{mus} belong to the music class @code{type}?"
   (memq type (ly:music-property mus 'types)))
 
+(define-safe-public (music-type-predicate types)
+  "Returns a predicate function that can be used for checking
+music to have one of the types listed in @var{types}."
+   (if (cheap-list? types)
+       (lambda (m)
+         (any (lambda (t) (music-is-of-type? m t)) types))
+       (lambda (m) (music-is-of-type? m types))))
+
 ;; TODO move this
 (define-public ly:grob-property
   (make-procedure-with-setter ly:grob-property