On 2020-06-09 12:43 pm, Paolo Prete wrote:
Hello,

I don't understand how to use a fraction as a parameter for a scheme
function. More specifically, this gives me an error:

%%%%%%%%%%%%

proportionalNotationDur = #(define-music-function (parser location frac)
(scheme?)                          #{ \set
Score.proportionalNotationDuration = #(ly:make-moment frac) #})
{
  \proportionalNotationDur 1/16
  c' c' c' c'
}

%%%%%%%%%%%%

You should use the fraction? type predicate if you want to accept 1/16 for input. The resulting value is a pair with the numerator as the car and the denominator as the cdr.

Alternately, you can use the rational? type predicate so the value is numeric. However, you will then need to use Scheme syntax for the input: #1/16 instead of 1/16.


-- Aaron Hill

Reply via email to