Hi,
I tried to create a function which should accept a pitch _or_ music.
So I defined a pitch-or-music? predicate:
#(define (pitch-or-music? x)
(or (ly:pitch? x) (ly:music? x)))
Calling the function, I have to use ##{ ... #} for music _and_ for a
single pitch.
Calling the function for a single pitch doesn't work, if ##{ #} are
omitted, but it'll work if the predicate would be ly:pitch?
I don't understand this behaviour.
To demonstrate it, I created the following simplified function:
\version "2.16.0"
#(define (pitch-or-music? x)
(or (ly:pitch? x) (ly:music? x)))
dummyFunction =
#(define-music-function (parser location pitch-or-music color mus)
(pitch-or-music? list? ly:music?)
;; (ly:pitch? list? ly:music?)
(newline)(display "pitch? ")(write (ly:pitch? pitch-or-music))
(newline)(display "music? ")(write (ly:music? Pitch-or-music))
;; some dummy-commands:
(if (ly:pitch? pitch-or-music)
#{
\override NoteHead #'color = $(car color)
$mus
#}
#{
\override NoteHead #'color = $(cadr color)
$mus
#}))
\relative c' {
\dummyFunction
c % works only, if the predicate is ly:pitch?
%##{ c #} % works
%##{ c d e #} % works
#`(,red ,green)
c1
}
Is there any possibility to get rid of ##{ #}, when calling the
function with a single pitch, but to keep the possibility to call it
with some music?
Regards,
Harm
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user