Urs Liska <u...@openlilylib.org> writes:

>> \version "2.18.0"
>>
>> myNotes =
>> #(define-music-function (parser location note num)
>>     (ly:music? number?)
>>     "Returns a series of notes. @var{note} is repeated @var{num} times.
>>     @var{note} is supposed to be a single note."
>>     ;; iteration by named let
>>     (let loop
>>       ;; two variables/arguments,
>>       ;; i is the iteration count
>>       ;; nts is the list of notes we're building
>>       ((i 0)
>>        (nts '()))
>>
>>       ;; conditional
>>       (cond
>>        ((< i num)
>>         ;; call the loop again with modified values for i and nts
>>         (loop
>>          (+ i 1)
>>          (append nts (list (ly:music-deep-copy note)))))
>>
>>        (else
>>         ;; when done, return the music
>>         (make-music 'SequentialMusic 'elements nts)))))
>>

In this case, it is likely easier to replace the named let with
(make-sequential-music
  (ly:music-deep-copy
    (make-list num note)))

Which is a bit of a dead end for further manipulation which one would
likely do with map or similar on the list returned by
ly:music-deep-copy.

-- 
David Kastrup

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

Reply via email to