|
From: | Urs Liska |
Subject: | Re: Having trouble understanding optional and variable amount of arguments |
Date: | Thu, 1 Mar 2018 18:52:54 +0100 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 |
Am 01.03.2018 um 18:31 schrieb Stefano
Troncaro:
Look at https://github.com/openlilylib/scholarly/blob/master/usage-examples/annotate.ly to see an example for the syntax. Actually this does what you want: an unlimited number of optional arguments. %%% \version "2.19.80" #(define (context-mod->props mod) (map (lambda (prop) (cons (cadr prop) (caddr prop))) (ly:get-context-mods mod))) myVariableFunc = #(define-void-function (opts mus)((ly:context-mod? #f) ly:music?) (let ((props (if opts (context-mod->props opts) '()))) (for-each (lambda (prop) (ly:message "Option '~a': '~a'" (car prop) (cdr prop))) props) mus)) \relative { c' d e f \myVariableFunc \with { first = "Hello" second = 124 third = #'((a . red)(b . blue)) fourth = #(ly:version) fifth = #display } g1 } %%% Note that instead of defining context-mod->props you could include "oll-core/package.ily" (or rather: if you have included anything from OLL you can simply use that procedure. HTH Urs |
[Prev in Thread] | Current Thread | [Next in Thread] |