David Kastrup <d...@gnu.org> writes: > Kai Lautenschläger <kai.lautenschlae...@me.com> writes: > >>> Am 22.09.2012 um 12:42 schrieb: >>> >>>> At some point of time, we probably should have a convenience function >>>> for the pattern >>>> >>>> (reverse! (fold-some-music [predicate] >>>> (lambda (l m) (cons ([extractor] m) l)) >>>> '() >>>> [music])) >>>> >>>> The example code I posted uses this twice already. >> >> >> Thanks for explaining. As for your idea [above] I would like that >> feature very much, though I do not understand the code because I am >> illiterate to programming languages. > > It turns out that the ([extractor] m) pattern can be equally well done > separately using map!, so actually every function needed here is already > available, making this somewhat simpler:
And actually, one does not need to nest the #{ #} constructs here, so the following will do fine:
\language "deutsch" rhythm = { s8.[ s16] } melody = \relative c { a d g f e b} applyRhythm = #(define-music-function (parser location rhythm melody) (ly:music? ly:music?) #{ $@(append-map cons (map! (lambda (m) (ly:music-property m 'pitch)) (extract-music melody (lambda (m) (ly:music-property m 'pitch #f)))) (apply circular-list (map! (lambda (m) (cons (ly:music-property m 'duration) (ly:music-property m 'articulations))) (extract-typed-music rhythm 'skip-event)))) #}) \score { \new Voice { \relative c { g2 d8 h e4 f } \applyRhythm \rhythm \melody \relative c { g2 d8 h e4 f } } \layout { } }
-- David Kastrup
_______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user