[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: scheme (format) question
From: |
Carl D. Sorensen |
Subject: |
Re: scheme (format) question |
Date: |
Sat, 21 Mar 2009 15:38:31 -0600 |
On 3/21/09 1:34 AM, "Mark Polesky" <address@hidden> wrote:
>
>
> \version "2.12.2"
>
> %{
>
> How can I change the following code so that
> it returns "2 0.25 0.3333"? That is: return
> integers without decimal point, otherwise
> round to as many decimal places as needed,
> but not more than 4.
>
> %}
>
> #(let ((a 2.0)
> (b 1/4)
> (c 1/3))
> (format #t "~a ~a ~a\n" a b c))
>
> %{
>
> After some experimenting, I found the
> following solution, but I'd rather not have
> to deal with all the incessant quasiquote
> and unquote stuff. Is there a more elegant
> solution?
>
<snip>
>
> #(let ((a 2.0)
> (b 1/4)
> (c 1/3))
> (my-format #t "~a ~a ~a\n" `(,a ,b ,c)))
>
#(let ((a 2.0)
(b 1/4)
(c 1/3))
(my-format #t "~a ~a ~a\n" (list a b c)))
will work.
Carl