[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Function for rendering key textually in 3 languages
From: |
Olivier Biot |
Subject: |
Re: Function for rendering key textually in 3 languages |
Date: |
Sat, 3 Nov 2012 18:11:48 +0100 |
On Sat, Nov 3, 2012 at 5:54 PM, David Kastrup <address@hidden> wrote:
> Olivier Biot <address@hidden> writes:
>
>> I definitely have problems with Scheme and LilyPond interpretation. I
>> now have the Scheme standard open as well.
>>
>> I tried to simplify the initial job by first creating a function with
>> one string argument returning either a string or a markup. Does not
>> work.
>>
>> I tried hundreds of alternatives, with musoc-function and withj
>> markup-command, with a define and define-scheme-funciton, to no avail.
>>
>> Why is the following not working?
[...]
> One reason is because markup commands have rather rudimentary argument
> parsing (to make you appreciate the work done on music functions more,
> ha ha) and distinguish only markup, markup list, and Scheme as argument
> type. A quoted LilyPond string counts only as "markup". And markup
> commands can only be used inside of explicit markup.
>
> Then you use ( ) where they don't belong. Remember: those are _not_
> mere grouping constructs but form a list. And a list of lists is
> something different from a list. In evaluated contexts (like this is),
> ( ) are a function call. So you try calling "C sharp" as a function
> (which does not work) and call the result of the cond as a function
> again (which also does not work).
>
> Just because Scheme seems to be crawling with parens does not mean that
> you can throw in a few more and hope that nobody will notice.
>
> '"cis" is awfully awkward (strings are self-quoting and don't need '
> before them) but not actually wrong.
>
>> \header {
>> composer = "myself"
>> title = \tonicEN "cis"
>> }
>
> You would likely have to write
>
> title = \markup \tonicEN #"cis"
>
> here after fixing the above definition. Alternatively, use
>
> tonicEn =
> #(define-scheme-function (parser layout tonic) (string?) ...
>
> in which case title = \toniEN "cis" should work fine. With the current
> development version, you should be able to use \tonicEN pretty much
> everywhere a string can be used, with 2.16.0 the uses will likely be
> more restrained. On the right side of an assignment or as a function
> argument, however, should work fine all the time.
>
> --
> David Kastrup
Hi David,
Thanks a lot - I now start to see the mistakes I made (excess
parentheses around the cond expression and excess parentheses around
the return values in the cond sub expressions).
I have however to use quotes around the note name for it to work.
Here's code that actually works, maybe it can be useful for others:
%%% BEGIN SNIPPET
\version "2.16.0"
tonicEN = #(define-scheme-function (parser layout tonic) (string?)
(
cond
( (string=? tonic "cis") "C sharp" )
( (string=? tonic "dis") "D sharp" )
)
)
\header {
composer = "myself"
title = \tonicEN "cis"
}
\score {
\relative c' {
a bes cis deses e fisis ges
}
\layout {}
}
%%% END SNIPPET
- Re: Function for rendering key textually in 3 languages, Olivier Biot, 2012/11/02
- Re: Function for rendering key textually in 3 languages, Olivier Biot, 2012/11/03
- Re: Function for rendering key textually in 3 languages, David Kastrup, 2012/11/03
- Re: Function for rendering key textually in 3 languages,
Olivier Biot <=
- Re: Function for rendering key textually in 3 languages, Olivier Biot, 2012/11/03
- Re: Function for rendering key textually in 3 languages, David Kastrup, 2012/11/03
- Re: Function for rendering key textually in 3 languages, Olivier Biot, 2012/11/03
- Re: Function for rendering key textually in 3 languages, Thomas Morley, 2012/11/04
- Re: Function for rendering key textually in 3 languages, Thomas Morley, 2012/11/04
- Re: Function for rendering key textually in 3 languages, Olivier Biot, 2012/11/04
- Re: Function for rendering key textually in 3 languages, Thomas Morley, 2012/11/04