[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: converting decimal numbers into rational in scheme functions
From: |
Thomas Morley |
Subject: |
Re: converting decimal numbers into rational in scheme functions |
Date: |
Wed, 18 Sep 2013 02:36:47 +0200 |
2013/9/18 David Kastrup <address@hidden>:
> 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 #})
Also possible:
#(fraction->moment (cons 1 32))
Cheers,
Harm
>
>> i'm probably doing something stupid here...
>
> Depends on your level of Scheme knowledge.
>
> --
> David Kastrup
>
> _______________________________________________
> lilypond-user mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/lilypond-user