On 15 May 2018 at 12:10, David Kastrup <[email protected]> wrote:

> Malte Meyn <[email protected]> writes:
>
> > Am 15.05.2018 um 10:27 schrieb Gianmaria Lari:
> >> Thank you Gilles!!!! I have yet a problem, how can engrave the foo
> >> generated list in a score?
> >
> > You should make a music-function:
> >
> > \version "2.19.81"
> >
> > foo =
> > #(define-music-function (seq1 seq2) (ly:music? ly:music?)
> >    (make-sequential-music
> >     (map (lambda (note)
> >            (make-sequential-music
> >             (cons note (ly:music-property seq2 'elements))))
> >       (ly:music-property seq1 'elements))))
> >
> > seqI = { c b a }
> > seqII = { f g }
> >
> > \foo \seqI \seqII
>
> Nope.  You need to write
>
> (ly:music-deep-copy (ly:music-property seq2 'elements))
>
> instead of
> (ly:music-property seq2 'elements)
>
> here or you'll get surprising results whenever the result is changed in
> place (like when transposing the result).
>
> Incidentally, it might make sense to write instead
>
> foo =
> #(define-music-function (seq1 seq2) (ly:music? ly:music?)
>   (set! (ly:music-properties seq1 'elements)
>     (map! (lambda (note)
>       (music-clone seq2
>       'elements (cons note (music-clone (ly:music-property seq2
> 'elements)))))
>       (ly:music-property seq1 'elements)))
>   seq1)
>
> That will take the structure of the respective sequences as templates,
> so you can use <<...>> instead of {...} for either and have this
> reflected in the result.  Also <...> though that will make sense only
> for the inner structure.
>

David I copied and pasted you code but it didn't compile. I changed
ly:music-properties to ly:music-property but it doesn't compile anyway.
This is the complete code:

\version "2.19.81"
foo =
#(define-music-function (seq1 seq2) (ly:music? ly:music?)
  (set! (ly:music-property seq1 'elements)
    (map! (lambda (note)
      (music-clone seq2
      'elements (cons note (music-clone (ly:music-property seq2
'elements)))))
      (ly:music-property seq1 'elements)))
  seq1)

seqI = { c b a }
seqII = { f g }

{\foo \seqI \seqII}

... and this is the error I get

Starting lilypond-windows.exe 2.19.81 [Untitled (9)]...

Processing
`C:/Users/GIANMA~1/AppData/Local/Temp/frescobaldi-f2cfs6t1/tmpj6o5qsf6/
document.ly'

Parsing...C:/Program Files
(x86)/LilyPond/usr/share/lilypond/current/scm/music-functions.scm:1063:31
<0>: In procedure ly:music-mutable-properties in expression
(ly:music-mutable-properties music):

C:/Program Files
(x86)/LilyPond/usr/share/lilypond/current/scm/music-functions.scm:1063:31
<1>: Wrong type argument in position 1 (expecting Prob): (#<Prob: Music
C++: Music((pitch . #<Pitch f >) (duration . #<Duration 4 >) (origin .
#<location
C:/Users/GIANMA~1/AppData/Local/Temp/frescobaldi-f2cfs6t1/tmpj6o5qsf6/document.ly:12:11>))((display-methods
#<procedure #f (note)>) (name . NoteEvent) (iterator-ctor .
#<primitive-procedure ly:rhythmic-music-iterator::constructor>) (types
event note-event rhythmic-event melodic-event)) >

#<Prob: Music C++: Music((pitch . #<Pitch g >) (duration . #<Duration 4 >)
(origin . #<location
C:/Users/GIANMA~1/AppData/Local/Temp/frescobaldi-f2cfs6t1/tmpj6o5qsf6/document.ly:12
<2>:13>))((display-methods #<procedure #f (note)>) (name . NoteEvent)
(iterator-ctor . #<primitive-procedure
ly:rhythmic-music-iterator::constructor>) (types event note-event
rhythmic-event melodic-event)) >

)

Exited with return code 1.


g.
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to