[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
predicate pitch-or-music? - getting rid of ##{ #} ?
From: |
Thomas Morley |
Subject: |
predicate pitch-or-music? - getting rid of ##{ #} ? |
Date: |
Fri, 19 Oct 2012 20:17:27 +0200 |
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
- predicate pitch-or-music? - getting rid of ##{ #} ?,
Thomas Morley <=
- Re: predicate pitch-or-music? - getting rid of ##{ #} ?, David Kastrup, 2012/10/19
- Re: predicate pitch-or-music? - getting rid of ##{ #} ?, Thomas Morley, 2012/10/19
- Re: predicate pitch-or-music? - getting rid of ##{ #} ?, Janek Warchoł, 2012/10/21
- Re: predicate pitch-or-music? - getting rid of ##{ #} ?, David Kastrup, 2012/10/23
- Re: predicate pitch-or-music? - getting rid of ##{ #} ?, Janek Warchoł, 2012/10/24
- Re: predicate pitch-or-music? - getting rid of ##{ #} ?, David Kastrup, 2012/10/24
- Re: predicate pitch-or-music? - getting rid of ##{ #} ?, Janek Warchoł, 2012/10/24
- Re: predicate pitch-or-music? - getting rid of ##{ #} ?, Thomas Morley, 2012/10/24
- Re: predicate pitch-or-music? - getting rid of ##{ #} ?, Werner LEMBERG, 2012/10/24