On Wed, Jan 18, 2017 at 2:04 PM, David Kastrup <d...@gnu.org> wrote:
> Simon Albrecht <simon.albre...@mail.de> writes:
>
>> Hello,
>>
>> surely I overlooked something:
>>
>> I’m writing a function to truncate MMRs for rehearsal MIDI. This is
>> the code so far:
>>
>> %%%%%%%%%%%%%
>> \version "2.19.53"
>>
>> truncateRests =
>> #(define-music-function (mus) (ly:music?)
>>    (let ((trunc-rests (lambda (e) (if (music-is-of-type? e
>> 'multi-measure-rest-event)
>>                                      (ly:music-set-property! e
>> 'duration (ly:make-duration -1))))))
>>      (musicMap trunc-rests mus)))
>>
>> \truncateRests { \time 4/2 R\breve*10 }
>> %%%%%%%%%%%%%%
>>
>> Now Lily complains on that, saying ‘document.ly:9:1: error: music
>> function cannot return ##<unspecified>’. I’m puzzled – musicMap is
>> itself a music function, so how could truncateRests not return music?
>
> Because trunc-rests doesn't?
>
> Its last expression should be e but instead is
>
> (if ... (ly:music-set ...))
>
> which evaluates to *undefined* .
>

Just about to reply with:

truncateRests =
#(define-music-function (mus) (ly:music?)
   (let ((trunc-rests (lambda (e) (if (music-is-of-type? e
'multi-measure-rest-event)
                                      (ly:music-set-property! e
'duration (ly:make-duration -1)))
                        e)))
     (musicMap trunc-rests mus)))

-DN

_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to