lilypond-user
[Top][All Lists]
Advanced

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

Re: converting decimal numbers into rational in scheme functions


From: David Kastrup
Subject: Re: converting decimal numbers into rational in scheme functions
Date: Wed, 18 Sep 2013 02:30:40 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Janek Warchoł <address@hidden> writes:

> 2013/9/18 David Kastrup <address@hidden>:
>> Janek Warchoł <address@hidden> writes:
>>> 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)
>>
>> How did you search?  It's right in the GUILE manual where one would
>> expect, with rational numbers.
>
> I've grepped through LilyPond sources for various keywords, and looked
> around definitions of other conversions.
> I guess i should add guile manual to my RTFM list.
>
> In the meantime, i have trouble with converting from a fraction to a
> moment - this returns an error:
>
> \version "2.16.2"
>
> foof =
> #(define-music-function (parser location) ()
>    #{
>      \override Score.SpacingSpanner.common-shortest-duration =
>      #(fraction->moment (1 32))
>    #})

(1 32) tries to call 1 with 32 as its argument.  Just write

#(ly:make-moment 1/32)

and be done.  If you really, really don't remember how LilyPond
represents fractions and you really, really want to use
fraction->moment, you can write

#(fraction->moment #{ 1/32 #})

> i'm probably doing something stupid here...

Depends on your level of Scheme knowledge.

-- 
David Kastrup



reply via email to

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