lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Making two functions into one


From: Jean Abou Samra
Subject: Re: Making two functions into one
Date: Mon, 16 Jan 2023 19:45:04 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0

Le 16/01/2023 à 15:12, | || | | a écrit :
So I thought about delete one nested (list) and try it:

nd =  #(define-music-function (number) (integer?)
          (make-music
          'TimeSignatureMusic
          'numerator
          8
          'denominator
          8
          'beat-structure
          '())
        (make-music
          'UnfoldedRepeatedMusic
          'elements
          '()
          'repeat-count
          8
          'element
          (make-music
            'SequentialMusic
            'elements
            (list (make-music
                    'SkipEvent
                    'duration
                    (ly:make-duration 3))))))


But the problem is, when I don't use (list) for two adjacent (make-music) functions, one of them doesn't run, so depending on the kind of second (make-music) code, one od them goes, another don't.




David already explained the missing 'origin. I just want to explain
why this drops the first expression: it has nothing to do with LilyPond,
it's just the way Scheme works. When you have a sequence of expressions
like this in the body of a function, they are evaluated in turn, and
the value of the last one is returned. The others are discarded. They
can only be useful if they have "side effects", like (display ...)
for example.

Best,
Jean

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]