[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
converting decimal numbers into rational in scheme functions
From: |
Janek Warchoł |
Subject: |
converting decimal numbers into rational in scheme functions |
Date: |
Wed, 18 Sep 2013 01:34:35 +0200 |
Hi,
i have a function that takes a moment as the argument:
foo =
#(define-music-function (parser location mom)
(ly:moment?)
#{
\override Score.SpacingSpanner.base-shortest-duration = #mom
#})
\new Staff {
\foo #(ly:make-moment 1 50)
c'4 d' e' f'
}
Now, i would like to be able to supply a decimal number and have it
converted to a rational number (i.e. a fraction, which can be easily
converted to a moment), so that i could call the function like this
\foo #0.02 % 1/50 = 0.02
Is there any smart way to do this (a built-in function? I've searched
for one but haven't found any), or do i have to write a
decimal->rational converter? Would anyone want to help with this?
best,
Janek
- converting decimal numbers into rational in scheme functions,
Janek Warchoł <=