Re: function argument computation

2011-02-25 Thread Michael Ellis
On Fri, Feb 25, 2011 at 9:20 AM, Peter Buhr  wrote:

> specialB = #(define-music-function (parser location suffix) (string?)
> #{
>\base (concat "XXX" $suffix) #$suffix   % DOES NOT WORK
> #})
>

Hi Peter,
I think the following does what you're looking for.

specialB =
 #(define-music-function (parser location suffix) (string?)
(define combined (string-append "XXX" suffix))
   #{
   \base $combined $suffix
   #})

Cheers,
Mike
___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


function argument computation

2011-02-25 Thread Peter Buhr
I'm trying to factor out common code in some music functions. Below is a
fragment of the code illustrating my problem. It's been years since I've used
Lisp so please appreciate the naivety in this question.

I want to do a computation at the call and pass the result as an argument to
a function parameter:

\base (concat "XXX" $suffix) #$suffix   % DOES NOT WORK

I've tried a number of things but I'm just guessing. Is this possible? And if
it is possible, what is the syntax?



\version "2.13.40"
\include "english.ly"
#(set-default-paper-size "letter")
#(set-global-staff-size 24)

base = #(define-music-function (parser location prefix suffix) (string? string?)
#{
\once \override TextSpanner #'bound-details #'left #'text = \markup { 
\concat { $prefix ":" $suffix } }
#})

specialA = #(define-music-function (parser location suffix) (string?)
#{
\base #"Foo" #$suffix
#})

specialB = #(define-music-function (parser location suffix) (string?)
#{
\base (concat "XXX" $suffix) #$suffix   % DOES NOT WORK
#})

\score {
\relative c' {
\base #"Foo" #"Bar" a \startTextSpan b c d e g \stopTextSpan
\specialA #"Bar"a \startTextSpan b c d e g \stopTextSpan
\specialB #"YYY"a \startTextSpan b c d e g \stopTextSpan
} % relative
} % score

% Local Variables: %
% tab-width: 4 %
% compile-command: "lilypond --ps test.ly" %
% End: %

___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user