lilypond-user
[Top][All Lists]
Advanced

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

Passing along variable-number arguments


From: Urs Liska
Subject: Passing along variable-number arguments
Date: Tue, 2 Feb 2016 00:30:37 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1

Hi,

I'm hitting a wall with Scheme once more.
I need to create wrapper functions around (format) and other functions
that need a variable number of arguments.

I know that with

    #(define (my-proc fmt . vals)

"vals" will be an arbitrary number of arguments that will be wrapped in
a list, and I know how to access the individual items or this list from
within the function. But what I don't understand is how to pass exactly
the original arguments (*not* packed in a list) to another function in
the body:

%%%%%%%%%%%%%%%%%%%%%%%

\version "2.19.35"

#(define (wrapper fmt . vals)
   (ly:message (format fmt vals)))

#(wrapper "This is the ~a format string\n" "listified")
%#(wrapper "This is the ~a and ~a format string\n" "listified" "broken")

%%%%%%%%%%%%%%%%%%%%%%%

In this code "format" receives "fmt" (the format strings) and "vals" -
the *list* of arguments.
How should I modify this so "format" doesn't parenthesize the output and
also works with more than one argument and placeholder in the format string?

Thank
Urs



reply via email to

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