[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Replace ly:music elements in a Scheme function
From: |
David Kastrup |
Subject: |
Re: Replace ly:music elements in a Scheme function |
Date: |
Mon, 05 Mar 2018 17:28:52 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) |
paolo prete <address@hidden> writes:
> Hello David,
> thanks for the snippet but I ask if it is possible to modify only the body
> of my function, inside lambda (x y)( ... ) so to obtain the same result.
> Something like:
>
>
> %%%%%%%%
>
> fun = #(define-music-function (parser location music1 music2) (ly:music?
> ly:music?)
> (let
> (
> (musicList1 (ly:music-property music1 'elements))
> (musicList2 (ly:music-property music2 'elements))
> )
> (map
> (lambda (x y)
> ;
> ; place HERE the code for copying the WHOLE y element to the
> whole x element
> ; (where y and x have the same position in their corresponding
> lists)
> ;
> )
> musicList1 musicList2
> )
> )
> #{ $music1 #})
No. x and y are values stored in lists. The relation to their lists is
not passed into your function, so you cannot change it there.
You'd need to use something like pair-for-each to modify the first list
in-place, and that gets old fast as music structures change.
There is an actual reason functions like map-some-music are provided.
--
David Kastrup