2015-08-10 19:02 GMT+02:00 Thomas Morley <[email protected]>:
> Hi all,
>
> I want to put out 3/2 not as 1.5 but "1½" or "1 1/2"
> Is there a predefined procedure in guile or do I need to define my own?
>
> Thanks,
> Harm
It's a matter of "exactness".
And when #e comes into the game the guile-manual is not verbose about it.
To say the least.
In the end I come up with the below. I decided to return a ist, not a string.
But it feels pretty clumsy, noone with something better?
(define (integer-and-fraction nmbr)
"Return a list with an integer and a fraction build from an exact number
Example: 47/7 -> (6 5/7) "
(let* ((i (inexact->exact (truncate nmbr)))
(rest (string->number (format #f "~a~a" "#e" (- nmbr i)))))
;; return a string
;(format #f "~a~a"
; i
; (if (= rest 0)
; ""
; (string-append " " (number->string rest))))
;; return a list
(list i rest)
))
(display (integer-and-fraction (/ 1111 7)))
Cheers,
Harm
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user