Jean Abou Samra <j...@abou-samra.fr> writes:

> Le 26/03/2022 à 03:23, Kieren MacMillan a écrit :
>> Hope that makes it clearer?
>
>
> Yes, I understand better, thanks. I'd just suggest changing your
> snippet to
>
> \version "2.23.7"
>
> $(let ((notes (ly:music-property #{ <e f g a b c' d' e' f' g' a' b' c'
> d'> #} 'elements)))
>     (make-sequential-music
>      (map (lambda (x) (ly:music-deep-copy (list-ref notes (random
> (length notes)))))
>           (iota 400))))
>
>
> with the essential change being the insertion of a
> ly:music-deep-copy so it does not share the same music
> objects for different notes, which could go wrong with
> the application of some music functions.

It doesn't share the same music objects for different notes since $(...)
makes a ly:music-deep-copy anyway that will deduplicate the elements of
SequentialMusic while copying them.  The intermediate expression is
indeed not fit for every use, but the final deep copy fixes that.

-- 
David Kastrup

Reply via email to