Re: Workaround for (not-allowed) numbers in variable names?

2021-03-10 Thread Valentin Petzel
Hello Stefano,

Here’s an improved version that also allows for Markup between the examples.

Cheers,
Valentin#(define (string-replace-substring s substring replacement)
  "Replace every instance of substring in s by replacement."
  (let ((sublen (string-length substring)))
(with-output-to-string
  (lambda ()
(let lp ((start 0))
  (cond
   ((string-contains s substring start)
=> (lambda (end)
 (display (substring/shared s start end))
 (display replacement)
 (lp (+ end sublen
   (else
(display (substring/shared s start)

catScore=
#(define-scheme-function (music title) (ly:music? string?)
   #{
 \score {
   \header {
 piece = \markup { #title }
   }
   #music
   \layout { }
 }
   #})

catMarkup=
#(define-scheme-function (text title) (markup? string?)
   #{
 \markup {
   \column {
 \line { #title }
 \line { #text }
 \vspace #0.5
   }
 }
   #})

addScore = #(define-void-function (score) (ly:score?) (add-score score)) 


% List contains eighter scores, or lists (score title="" count?=#t append?=#t sep="")
% Set title to a string, {idx} is replaced by current count. Set count?=#f to not count
% the current score, e.g. Ex. 2 and Ex. 2b. Set append?=#f to not append title to Ex. {idx},
% but to replace it. If append?=#t you may sep sep as Separator between Ex. {idx} and title
% can also take nested pairs (score title count append . sep)
%
% if score is music it is counted by default, if markup not
% if score is markup we replace the title by default
catScores=
#(define-void-function (listOfScores i) (list? number?)
   (if (not (null? listOfScores))
   (let* (
   (current (car listOfScores))
   (score (if (and (not (markup? current)) (pair? current)) (car current) current))
   (rest1 (if (and (not (markup? current)) (pair? current)) (cdr current) '()))
   (fmt   (if (null? rest1) ""
  (if (pair? rest1) (car rest1)
  rest1)))
   (rest2 (if (pair? rest1) (cdr rest1) '()))
   (count? (if (null? rest2) (ly:music? score)
(if (pair? rest2) (car rest2)
rest2)))
   (rest3 (if (pair? rest2) (cdr rest2) '()))
   (append?  (if (null? rest3) (ly:music? score)
(if (pair? rest3) (car rest3)
rest3)))
   (rest4 (if (pair? rest3) (cdr rest3) '()))
   (sep (if (null? rest4) ""
(if (pair? rest4) (car rest4)
rest4)))
   (fmt-real (if append? (string-join (list "Ex. {idx}" fmt) sep) fmt))
   (title (string-replace-substring fmt-real "{idx}" (if count? (+ 1 i) i)))
   )
 (if (ly:music? score)
 (add-score (catScore score title))
 (add-text (catMarkup score title)))
 (catScores (cdr listOfScores) (if count? (+ 1 i) i)
 

#(define catA (list
   #{ \markup\justify{ This Category contains Examples of very shady nature. Practise
   them with care, or they might eat your furniture! You’ve been warned! Really!
   This is the last chance to turn back!} #}
   #{ c'4 e'8 e' g' f' e'4 #}
   #{ d'4 4 16 16 e'8 g' d' #}
   #{ e'8 8 f' f' d' d' g4 #}
   (markup #:justify ( "This" "example" "has" "two" "unrelated" "subexamples." "Don’t" "ask" "for" "the" "reason ..."))
   (list #{ c'4 e'8 e' g' f' e'4 #} "b" #f) ; do not count and append b
   (list #{ d'4 4 16 16 e'8 g' d' #} "Example {idx}" #t #f) ; count and replace
   (list #{ \markup\justify{ A counted markup with title.} #} "" #t #t)
   (list #{ e'8 8 f' f' d' d' g4 #} "The Title" #t #t ": ") ; count, append, use : as sep
   ))


\markup "Only printing one category this time"

\catScores #catA 0

#(define catB (list
   #{ \time 2/3 \times 2/3 { f'4 g' a' e' } #}
   #{ \new StaffGroup <<
 \new Staff { c'8 d' e' f' e' d' c'4 } 
 \new Staff {\clef bass c4 g f e }
   >> #}
   #{  \new TabStaff { e, g b e' } #}))

printCats=
#(define-void-function (listOfCategories) (list?)
   (if (not (null? listOfCategories))
   (begin
 (add-text
  #{
   \markup\column{\larger\larger\larger\line { Category #(car (car listOfCategories)) } \vspace #0.6 }
  #})
 (catScores (cdr (car listOfCategories)) 0)
 (printCats (cdr listOfCategories)

#(define cats (list (cons "A" catA) (cons "B" catB)))

\bookpart {
\markup "Printing all categories"
\printCats #cats
}

signature.asc
Description: This is a digitally signed message part.


Re: Workaround for (not-allowed) numbers in variable names?

2021-03-10 Thread Valentin Petzel
Hello Stefano,

Here’s a slightly improved example, offering more control.

Cheers,
Valentin

Am Mittwoch, 10. März 2021, 05:31:07 CET schrieben Sie:
> Thank you for the example Valentin,
> 
> a very interesting approach.  I think I was headed in that direction, in
> fact, although you code will make me jump ahead quite a bit.
> 
> Cheers,
> 
> Stefano
> 
> On Fri, Mar 5, 2021 at 2:49 PM Valentin Petzel  wrote:
> > Hello Stefano,
> > 
> > You might try to keep the whole thing dynamic and leave the numbering and
> > stuff to Lilypond. For example you could have just a list of all Examples
> > in
> > one Category and then have a function to print that out. You could even do
> > a
> > list of Categories and print them all at once. This way you could even
> > manage
> > your Scores anyway you want, and adding Examples to one Group requires
> > just
> > adding it to that list. See the appended File for an example.
> > 
> > Cheers,
> > Valentin#(define (string-replace-substring s substring replacement)
  "Replace every instance of substring in s by replacement."
  (let ((sublen (string-length substring)))
(with-output-to-string
  (lambda ()
(let lp ((start 0))
  (cond
   ((string-contains s substring start)
=> (lambda (end)
 (display (substring/shared s start end))
 (display replacement)
 (lp (+ end sublen
   (else
(display (substring/shared s start)

catScore=
#(define-scheme-function (music title) (ly:music? string?)
   #{
 \score {
   \header {
 piece = \markup { #title }
   }
   #music
   \layout { }
 }
   #})

addScore = #(define-void-function (score) (ly:score?) (add-score score)) 


% List contains eighter scores, or lists (score title="" count?=#t append?=#t sep="")
% Set title to a string, {idx} is replaced by current count. Set count?=#f to not count
% the current score, e.g. Ex. 2 and Ex. 2b. Set append?=#f to not append title to Ex. {idx},
% but to replace it. If append?=#t you may sep sep as Separator between Ex. {idx} and title
% can also take nested pairs (score title count append . sep)
catScores=
#(define-void-function (listOfScores i) (list? number?)
   (if (not (null? listOfScores))
   (let* (
   (current (car listOfScores))
   (score (if (pair? current) (car current) current))
   (rest1 (if (pair? current) (cdr current) '()))
   (fmt   (if (null? rest1) ""
  (if (pair? rest1) (car rest1)
  rest1)))
   (rest2 (if (pair? rest1) (cdr rest1) '()))
   (count? (if (null? rest2) #t
(if (pair? rest2) (car rest2)
rest2)))
   (rest3 (if (pair? rest2) (cdr rest2) '()))
   (append?  (if (null? rest3) #t
(if (pair? rest3) (car rest3)
rest3)))
   (rest4 (if (pair? rest3) (cdr rest3) '()))
   (sep (if (null? rest4) ""
(if (pair? rest4) (car rest4)
rest4)))
   (fmt-real (if append? (string-join (list "Ex. {idx}" fmt) sep) fmt))
   (title (string-replace-substring fmt-real "{idx}" (if count? (+ 1 i) i)))
   )
 (add-score (catScore score title))
 (catScores (cdr listOfScores) (if count? (+ 1 i) i)
 

#(define catA (list
   #{ c'4 e'8 e' g' f' e'4 #}
   #{ d'4 4 16 16 e'8 g' d' #}
   #{ e'8 8 f' f' d' d' g4 #}
   (list #{ c'4 e'8 e' g' f' e'4 #} "b" #f) ; do not count and append b
   (list #{ d'4 4 16 16 e'8 g' d' #} "Example {idx}" #t #f) ; count and replace
   (list #{ e'8 8 f' f' d' d' g4 #} "The Title" #t #t ": ") ; count, append, use : as sep
   ))


\markup "Only printing one category this time"

\catScores #catA 0

#(define catB (list
   #{ \time 2/3 \times 2/3 { f'4 g' a' e' } #}
   #{ \new StaffGroup <<
 \new Staff { c'8 d' e' f' e' d' c'4 } 
 \new Staff {\clef bass c4 g f e }
   >> #}
   #{  \new TabStaff { e, g b e' } #}))

printCats=
#(define-void-function (listOfCategories) (list?)
   (if (not (null? listOfCategories))
   (begin
 (add-text
  #{
   \markup\larger\larger\larger { Category #(car (car listOfCategories)) }
  #})
 (catScores (cdr (car listOfCategories)) 0)
 (printCats (cdr listOfCategories)

#(define cats (list (cons "A" catA) (cons "B" catB)))

\bookpart {
\markup "Printing all categories"
\printCats #cats
}

signature.asc
Description: This is a digitally signed message part.


Re: Workaround for (not-allowed) numbers in variable names?

2021-03-07 Thread David Wright
On Sun 07 Mar 2021 at 14:48:08 (+), Peter Toye wrote:
> The 2.22 documentation is obviously better here:
> 
> The name of a variable should not contain (ASCII) numbers, multiple 
> underscores, multiple dashes or space characters. All other characters 
> Unicode provides are allowed, for example Latin, Greek, Chinese or Cyrillic. 
> Non-adjacent single underscores and dashes are allowed, too. In other words, 
> variable names like HornIII or ???XII work.

Because Unicode is supported, one can avoid all these syntactic
complications by using any one or more of these number sets:

¹ superscripts
₂ subscripts
③ circled
⑷ parenthesised
⒌ bundled with a period
⓺ double circled

> Any combination of characters is allowed if the variable name is enclosed in 
> double quotation marks. In this case backslashes and double quotation marks 
> need to be escaped with backslashes (not that you actually should use them). 
> Examples: "foo bar", "a-b-c", "Horn 3". 

Cheers,
David.



Re: Workaround for (not-allowed) numbers in variable names?

2021-03-07 Thread Peter Toye
The 2.22 documentation is obviously better here:

The name of a variable should not contain (ASCII) numbers, multiple 
underscores, multiple dashes or space characters. All other characters Unicode 
provides are allowed, for example Latin, Greek, Chinese or Cyrillic. 
Non-adjacent single underscores and dashes are allowed, too. In other words, 
variable names like HornIII or ???XII work.

Any combination of characters is allowed if the variable name is enclosed in 
double quotation marks. In this case backslashes and double quotation marks 
need to be escaped with backslashes (not that you actually should use them). 
Examples: "foo bar", "a-b-c", "Horn 3". 

 
Regards,

Peter
mailto:lilyp...@ptoye.com
www.ptoye.com

Re: Workaround for (not-allowed) numbers in variable names?

2021-03-07 Thread Silvain Dupertuis

Hello,

Browsing the documentation,
I did not find anything about variable names with allowing non-alphabetic 
characters.
Did I miss something?

Here are extracts the 2.20 documentation

==


 3.1.1 Introduction to the LilyPond file structure <3.1.1 Introduction to 
the
 LilyPond file structure>

Remember that you can use almost any name you like as long _/as it contains just 
alphabetic characters/_ and is distinct from LilyPond command names. For more details, see 
Saving typing with variables and functions 
<http://lilypond.org/doc/v2.20/Documentation/learning/saving-typing-with-variables-and-functions>. 
The exact limitations on variable names are detailed in File structure 
<http://lilypond.org/doc/v2.20/Documentation/notation/file-structure>.



 3.4.4 Saving typing with variables and functions
 
<http://lilypond.org/doc/v2.20/Documentation/learning/saving-typing-with-variables-and-functions.html>

does not give any indication


 3.1.5 File structure
 <http://lilypond.org/doc/v2.20/Documentation/notation/file-structure.html>

_The name of a variable should have alphabetic characters only; no numbers, underscores or 
dashes_.



 Additional note :

It's a bit difficult for me to navigate through the English documentation for me... in a 
French language environment, as I can only get it by clicking at the bottom (why not at 
the top...), and links bring me back to French (which is also nice...). But anyhow, for 
this matter, the indications are the same.


Best regards
/Silvain/

Le 07.03.21 à 12:50, Peter Toye a écrit :
Re: Workaround for (not-allowed) numbers in variable names? Yes, it's documented in the 
Notation Reference Manual section 3.1.5 File Structure. It doesn't seem the obvious 
place to put the syntax of variable names.


Best regards,

Peter
mailto:lilyp...@ptoye.com <mailto:lilyp...@ptoye.com>
www.ptoye.com <http://www.ptoye.com>

-

> Message: 4
> Date: Sat, 6 Mar 2021 21:30:56 +0900
> From: 田村淳 mailto:j.tam...@me.com>>
> To: "lilypond-user@gnu.org" mailto:lilypond-user@gnu.org>>
> Subject: Re: Workaround for (not-allowed) numbers in variable names?
> Message-ID: <mailto:a9ba3c0b-fa05-4070-9927-ea24d559e...@me.com>>

> Content-Type: text/plain; charset="utf-8"

> Wow! This is something I’ve been looking for for a long time. Is this documented 
somewhere?


> Best regards,

> Jun
> https://imslp.org/wiki/User:Jun_T 
<https://imslp.org/wiki/User:Jun_T> <https://imslp.org/wiki/User:Jun_T 
<https://imslp.org/wiki/User:Jun_T>>


>> 2021/03/06 18:09、Richard Shann mailto:rich...@rshann.plus.com>>のメール:

>> On Fri, 2021-03-05 at 10:15 -0800, Mogens Lemvig Hansen wrote:
>>> I believe it was David K who made this magic work:
>>>
>>> \version "2.20.0"
>>>
>>> mus.1 = { c d e }
>>>
>>> \score {
>>>   \new Staff { \mus.1 }
>>> }
>>>

>> This can be extended to cover the case where a variable has two numbers
>> associated with it:

>> 8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><
>> \version "2.20.0"
>>
>> Movement.1.Staff.1 = { c d e }
>> Movement.1.Staff.2 = { c' d' e' }
>> Movement.2.Staff.1 = { f g a }
>> Movement.2.Staff.2 = { f' g' a' }
>> \score {
>>   <<
>>     \new Staff { \Movement.1.Staff.1 }
>>     \new Staff { \Movement.1.Staff.2 }
>>   >>

>> }
>> \score {
>>   <<
>>   \new Staff { \Movement.2.Staff.1 }
>>     \new Staff { \Movement.2.Staff.2 }
>>   >>

>> }

>> 8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><

>> (cautionary note: I haven't examined the code or docs on this, but it
>> seems a dot before and after will do the trick mid-word and a single
>> dot at end of word)

>> A decade or so ago I resorted to converting all the numbers to Roman
>> numerals using a C routine that's knocking around on the interweb...
>> time I upgraded that.

>> Richard Shann



>>> Regards,
>>> Mogens
>>>
>>> From: Silvain Dupertuis
>>> Sent: March 5, 2021 10:12
>>> To: lilypond-user@gnu.org <mailto:lilypond-user@gnu.org>
>>> Subject: Re: Workaround for (not-allowed) numbers in variable names?
>>>
>>> I also wondered why numbers are not allowed in variables.
>>> As for me, I used things like A, B, C instead... but it is less
>>> practical.
>>

Re: Workaround for (not-allowed) numbers in variable names?

2021-03-07 Thread David Kastrup
Peter Toye  writes:

> Thanks for putting me right yet again. I'm not quite sure what you
> mean by 'resized'.  q4 is surely legal?

Sure, but it's two chords, not one.

-- 
David Kastrup



Re: Workaround for (not-allowed) numbers in variable names?

2021-03-07 Thread Peter Toye
Thanks for putting me right yet again. I'm not quite sure what you mean by 
'resized'.  q4 is surely legal?

Best regards,

Peter
mailto:lilyp...@ptoye.com
www.ptoye.com

-
Sunday, March 7, 2021, 12:09:30 PM, David Kastrup wrote:

> Peter Toye  writes:

>> I asked this question some time ago, and David Kastrup was kind enough
>> to put me right.

>> The problem , as you mentioned, is in the way that numbers are used
>> for durations. Consider the following code:

>> chord = 
>> chord2= 

>> c1 \chord2

>> Should the second element be interpreted as 2 or 1? I
>> imagine this would confuse the lexer horribly.

> The lexer follows rules.  It's never confused.  The user is something
> different.  Incidentally, chords cannot be resized, so \chord2 would be
> interpreted as

>  2

> due to how isolated durations in music are interpreted.

>> No doubt some rules could be written to resolve this, but it would
>> need some recoding.

> Durations generally don't require space separation, like with a4 and so
> on.  Balancing conflicting desires and requirements and consistency is
> always tricky.  TeX has also chosen not to admit numbers into
> identifiers and people tend to complain it cramps their style.

Re: Workaround for (not-allowed) numbers in variable names?

2021-03-07 Thread Peter Toye
My personal view is that variables are important concepts and deserve a 
separate section somewhere - possibly 3.1.6 as a separate part of 'File 
Structure'. I note that the preceding section on markup text does not contain 
any detailed syntax definition - not even a link to the relevant section.

I'd do the mods myself, and tried to do some earlier, but  had difficulty in 
getting a Linux to work under a VM on my Windows machine. Unfortunately my 
health is a bit precarious and I can't take on any long-term projects.

Best regards,

Peter
mailto:lilyp...@ptoye.com
www.ptoye.com

-
Sunday, March 7, 2021, 12:34:45 PM, Werner LEMBERG wrote:


>> Yes, it's documented in the Notation Reference Manual section 3.1.5
>> File Structure.  It doesn't seem the obvious place to put the syntax
>> of variable names.

> Well, there is a proper index entry...  However, documentation for the
> 'foo.1.bar.2' trick is still missing.

> Do you have a better suggestion where this information should be
> presented in the Notation Reference?


> Werner

Re: Workaround for (not-allowed) numbers in variable names?

2021-03-07 Thread Werner LEMBERG


> Yes, it's documented in the Notation Reference Manual section 3.1.5
> File Structure.  It doesn't seem the obvious place to put the syntax
> of variable names.

Well, there is a proper index entry...  However, documentation for the
'foo.1.bar.2' trick is still missing.

Do you have a better suggestion where this information should be
presented in the Notation Reference?


Werner



Re: Workaround for (not-allowed) numbers in variable names?

2021-03-07 Thread David Kastrup
Peter Toye  writes:

> I asked this question some time ago, and David Kastrup was kind enough
> to put me right.
>
> The problem , as you mentioned, is in the way that numbers are used
> for durations. Consider the following code:
>
> chord = 
> chord2= 
>
> c1 \chord2
>
> Should the second element be interpreted as 2 or 1? I
> imagine this would confuse the lexer horribly.

The lexer follows rules.  It's never confused.  The user is something
different.  Incidentally, chords cannot be resized, so \chord2 would be
interpreted as

 2

due to how isolated durations in music are interpreted.

> No doubt some rules could be written to resolve this, but it would
> need some recoding.

Durations generally don't require space separation, like with a4 and so
on.  Balancing conflicting desires and requirements and consistency is
always tricky.  TeX has also chosen not to admit numbers into
identifiers and people tend to complain it cramps their style.

-- 
David Kastrup



Re: Workaround for (not-allowed) numbers in variable names?

2021-03-07 Thread Peter Toye
Yes, it's documented in the Notation Reference Manual section 3.1.5 File 
Structure. It doesn't seem the obvious place to put the syntax of variable 
names.

Best regards,

Peter
mailto:lilyp...@ptoye.com
www.ptoye.com

-

> Message: 4
> Date: Sat, 6 Mar 2021 21:30:56 +0900
> From: 田村淳 
> To: "lilypond-user@gnu.org" 
> Subject: Re: Workaround for (not-allowed) numbers in variable names?
> Message-ID: 
> Content-Type: text/plain; charset="utf-8"

> Wow! This is something I’ve been looking for for a long time. Is this 
> documented somewhere?

> Best regards,

> Jun
> https://imslp.org/wiki/User:Jun_T <https://imslp.org/wiki/User:Jun_T>

>> 2021/03/06 18:09、Richard Shann のメール:

>> On Fri, 2021-03-05 at 10:15 -0800, Mogens Lemvig Hansen wrote:
>>> I believe it was David K who made this magic work:
>>>  
>>> \version "2.20.0"
>>>  
>>> mus.1 = { c d e }
>>>  
>>> \score {
>>>   \new Staff { \mus.1 }
>>> }
>>>  

>> This can be extended to cover the case where a variable has two numbers
>> associated with it:

>> 8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><
>> \version "2.20.0"
>>  
>> Movement.1.Staff.1 = { c d e }
>> Movement.1.Staff.2 = { c' d' e' }
>> Movement.2.Staff.1 = { f g a } 
>> Movement.2.Staff.2 = { f' g' a' } 
>> \score {
>>   <<
>> \new Staff { \Movement.1.Staff.1 }
>> \new Staff { \Movement.1.Staff.2 }
>>   >>

>> }
>> \score {
>>   <<
>>   \new Staff { \Movement.2.Staff.1 }
>> \new Staff { \Movement.2.Staff.2 }
>>   >>

>> }

>> 8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><

>> (cautionary note: I haven't examined the code or docs on this, but it
>> seems a dot before and after will do the trick mid-word and a single
>> dot at end of word)

>> A decade or so ago I resorted to converting all the numbers to Roman
>> numerals using a C routine that's knocking around on the interweb...
>> time I upgraded that.

>> Richard Shann



>>> Regards,
>>> Mogens
>>>  
>>> From: Silvain Dupertuis
>>> Sent: March 5, 2021 10:12
>>> To: lilypond-user@gnu.org
>>> Subject: Re: Workaround for (not-allowed) numbers in variable names?
>>>  
>>> I also wondered why numbers are not allowed in variables.
>>> As for me, I used things like A, B, C instead... but it is less
>>> practical.
>>>  
>>> My guess is that it may be linked to the way numbers are used in
>>> notes and chords to indicate duration, otherwise it would be real
>>> nice to be able to use digits in variable names...!
>>>  
>>> Le 05.03.21 à 17:37, stefano franchi a écrit :
>>> Here is a question for anyone who may have been using lilypond for
>>> projects involving text and many, many, short and similar musical
>>> snippets.
>>>  
>>> I am putting together a book that will contain many (very brief) 
>>> exercises, grouped thematically. I had thought a convenient and
>>> flexible way to organize the material and keep future maintenance
>>> under control would be to create top level variables names for the
>>> main musical categories and sub-categories and then assign each score
>>> snippet to progressively numbered variable. So I would have, CategA-1 
>>> = {"code for one exercise"} , CategB-2 = "code for another
>>> exercise"}, and so on. Clean structure, easy to maintain and
>>> rearrange, etc.
>>>  
>>> Then I discovered that lilypond does not allow numbers in variable
>>> names :-(
>>>  
>>> I'd be willing to bet my use case is not particularly weird---there
>>> must have been other people encountering the same problem.
>>>  
>>> How have you guys managed it?
>>>  
>>> Cheers,
>>>  
>>> S.
>>>  

>>> --
>>> __
>>> Stefano Franchi

>>> stefano.fran...@gmail.com
>>> https://www.researchgate.net/profile/Stefano_Franchi
>>>  
>>> -- 
>>> Silvain Dupertuis
>>> Route de Lausanne 335
>>> 1293 Bellevue (Switzerland)
>>> tél. +41-(0)22-774.20.67
>>> portable +41-(0)79-604.87.52
>>> web: silvain-dupertuis.org
>>>  


> -- next part --
> An HTML attachment was scrubbed...
> URL: 
> <https://lists.gnu.org/archive/html/lilypond-user/attachments/20210306/5ed2846d/attachment.html>

> --

Re: Workaround for (not-allowed) numbers in variable names?

2021-03-07 Thread Peter Toye
I asked this question some time ago, and David Kastrup was kind enough to put 
me right.

The problem , as you mentioned, is in the way that numbers are used for 
durations. Consider the following code:

chord = 
chord2= 

c1 \chord2

Should the second element be interpreted as 2 or 1? I imagine 
this would confuse the lexer horribly. No doubt some rules could be written to 
resolve this, but it would need some recoding. Easier to stick with using 
quotes.

Best regards,

Peter
mailto:lilyp...@ptoye.com
www.ptoye.com

-

> Message: 2
> Date: Fri, 5 Mar 2021 18:17:02 +0100
> From: Silvain Dupertuis 
> To: lilypond-user@gnu.org
> Subject: Re: Workaround for (not-allowed) numbers in variable names?
> Message-ID: 
> Content-Type: text/plain; charset="utf-8"; Format="flowed"

> I also wondered why numbers are not allowed in variables.
> As for me, I used things like A, B, C instead... but it is less practical.

> My guess is that it may be linked to the way numbers are used in notes and 
> chords to 
> indicate duration, otherwise it would be real nice to be able to use digits 
> in variable 
> names...!

> Le 05.03.21 à 17:37, stefano franchi a écrit :
>> Here is a question for anyone who may have been using lilypond for projects 
>> involving 
>> text and many, many, short and similar musical snippets.

>> I am putting together a book that will contain many (very brief)  exercises, 
>> grouped 
>> thematically. I had thought a convenient and flexible way to organize the 
>> material and 
>> keep future maintenance under control would be to create top level variables 
>> names for 
>> the main musical categories and sub-categories and then assign each score 
>> snippet to 
>> progressively numbered variable. So I would have, CategA-1 = {"code for one 
>> exercise"} , 
>> CategB-2 = "code for another exercise"}, and so on. Clean structure, easy to 
>> maintain 
>> and rearrange, etc.

>> Then I discovered that lilypond does not allow numbers in variable names 
>> :-(

>> I'd be willing to bet my use case is not particularly weird---there must 
>> have been other 
>> people encountering the same problem.

>> How have you guys managed it?

>> Cheers,

>> S.


>> -- 
>> __
>> Stefano Franchi

>> stefano.fran...@gmail.com <mailto:stef...@tamu.edu>
>> /https://www.researchgate.net/profile/Stefano_Franchi/ 
>> <https://www.researchgate.net/profile/Stefano_Franchi>


> -- 
> Silvain Dupertuis
> Route de Lausanne 335
> 1293 Bellevue (Switzerland)
> tél. +41-(0)22-774.20.67
> portable +41-(0)79-604.87.52
> web: silvain-dupertuis.org <http://perso.silvain-dupertuis.org>
> -- next part --
> An HTML attachment was scrubbed...
> URL: 
> <https://lists.gnu.org/archive/html/lilypond-user/attachments/20210305/88659feb/attachment.html>

> --

Re: Workaround for (not-allowed) numbers in variable names?

2021-03-07 Thread David Kastrup
田村淳  writes:

> Thank you!
>
> Now I understand that keys separated by periods, for example,
> StaffGrouper.staff-staff-spacing.basic-distance = #7
> is a way to access a nested alist easily.

Yes, and it has been like that a long time.  Being able to access it
with

\StaffGrouper.staff-staff-spacing.basic-distance

is a newer development and I am not really sure that (for this alist) it
works in contexts where you could make use of it.  For music
expressions, it does work in the basic use case.

-- 
David Kastrup



Re: Workaround for (not-allowed) numbers in variable names?

2021-03-07 Thread 田村淳
Thank you!

Now I understand that keys separated by periods, for example,
StaffGrouper.staff-staff-spacing.basic-distance = #7
is a way to access a nested alist easily.

Jun

> 2021/03/07 17:26、Jean Abou Samra のメール:
> 
> Le 07/03/2021 à 03:03, 田村淳 a écrit :
> 
>> Hello David,
>> 
>>> gamme.1 is not a variable name.  It takes gamme to be an alist, and the
>>> entry under key 1 is what is addressed here.
>> Since you showed the Scheme equivalent below, I guess the above is a part of 
>> LilyPond syntax, or something the LilyPond parser does. Is that documented 
>> elsewhere? I’d like to know a bit more details.
>> 
>> Best regards,
>> 
>> Jun
> 
> Not really in an obvious place, but there is some text here:
> 
> https://lilypond.org/doc/v2.22/Documentation/notation/modifying-alists
> 
> Best,
> Jean
> 



Re: Workaround for (not-allowed) numbers in variable names?

2021-03-07 Thread Jean Abou Samra

Le 07/03/2021 à 03:03, 田村淳 a écrit :


Hello David,


gamme.1 is not a variable name.  It takes gamme to be an alist, and the
entry under key 1 is what is addressed here.

Since you showed the Scheme equivalent below, I guess the above is a part of 
LilyPond syntax, or something the LilyPond parser does. Is that documented 
elsewhere? I’d like to know a bit more details.

Best regards,

Jun


Not really in an obvious place, but there is some text here:

https://lilypond.org/doc/v2.22/Documentation/notation/modifying-alists

Best,
Jean




Re: Workaround for (not-allowed) numbers in variable names?

2021-03-06 Thread 田村淳
Hello David,

> gamme.1 is not a variable name.  It takes gamme to be an alist, and the
> entry under key 1 is what is addressed here.

Since you showed the Scheme equivalent below, I guess the above is a part of 
LilyPond syntax, or something the LilyPond parser does. Is that documented 
elsewhere? I’d like to know a bit more details.

Best regards,

Jun

> 2021/03/06 23:29、David Kastrup のメール:
> 
> Silvain Dupertuis  writes:
> 
>> I still checked this use of variable with numbers.
>> *Wonderful to see that it works.*
>> 
>> One important note, though:
>> If you use a numbered variable, _you cannot use the same variable
>> without an additional number_.
> 
> gamme.1 is not a variable name.  It takes gamme to be an alist, and the
> entry under key 1 is what is addressed here.
> 
> You can equivalently write gamme . #(- 3 2) for example.
> 
> In contrast, "gamme1" (referenced as \"gamme1") _is_ a single variable
> name.
> 
> As to converting numbers to roman numerals: what is wrong with
> 
> #(format #f "~@r" 547)
> 
> ?
> 
> -- 
> David Kastrup
> 




Re: Workaround for (not-allowed) numbers in variable names?

2021-03-06 Thread David Kastrup
Silvain Dupertuis  writes:

> I still checked this use of variable with numbers.
> *Wonderful to see that it works.*
>
> One important note, though:
> If you use a numbered variable, _you cannot use the same variable
> without an additional number_.

gamme.1 is not a variable name.  It takes gamme to be an alist, and the
entry under key 1 is what is addressed here.

You can equivalently write gamme . #(- 3 2) for example.

In contrast, "gamme1" (referenced as \"gamme1") _is_ a single variable
name.

As to converting numbers to roman numerals: what is wrong with

#(format #f "~@r" 547)

?

-- 
David Kastrup



Re: Workaround for (not-allowed) numbers in variable names?

2021-03-06 Thread Silvain Dupertuis

I still checked this use of variable with numbers.
*Wonderful to see that it works.*

One important note, though:
If you use a numbered variable, _you cannot use the same variable without an additional 
number_.


*This should be added somewhere in the documentation!*


   Here is a snippet.

\version "2.20.0"

\paper { indent = 0 }

global = {
  \key g \major
}

% --- Definition of variables ---
gamme.1 = \relative c'' { r4^\markup { "major" } g4 a b c d e fis g1 }
gamme.2 = \relative c'' { r2^\markup { "minor" } g a bes c d ees fis g1 }

\markup "Numbered variables : gamme.1 and gamme.2"
\markup "Trying to define a variable named \"gamme\" will throw an error"
\score {
  {
    \global \gamme.1 \gamme.2
  }
}



Wow! This is something I’ve been looking for for a long time. Is this 
documented somewhere?


Best regards,

Jun
https://imslp.org/wiki/User:Jun_T <https://imslp.org/wiki/User:Jun_T>

2021/03/06 18:09、Richard Shann <mailto:rich...@rshann.plus.com>>のメール:


On Fri, 2021-03-05 at 10:15 -0800, Mogens Lemvig Hansen wrote:

I believe it was David K who made this magic work:

\version "2.20.0"

mus.1 = { c d e }

\score {
  \new Staff { \mus.1 }
}



This can be extended to cover the case where a variable has two numbers
associated with it:

8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><
\version "2.20.0"

Movement.1.Staff.1 = { c d e }
Movement.1.Staff.2 = { c' d' e' }
Movement.2.Staff.1 = { f g a }
Movement.2.Staff.2 = { f' g' a' }
\score {
  <<
\new Staff { \Movement.1.Staff.1 }
\new Staff { \Movement.1.Staff.2 }
  >>

}
\score {
  <<
  \new Staff { \Movement.2.Staff.1 }
\new Staff { \Movement.2.Staff.2 }
  >>

}

8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><

(cautionary note: I haven't examined the code or docs on this, but it
seems a dot before and after will do the trick mid-word and a single
dot at end of word)

A decade or so ago I resorted to converting all the numbers to Roman
numerals using a C routine that's knocking around on the interweb...
time I upgraded that.

Richard Shann




Regards,
Mogens

From: Silvain Dupertuis
Sent: March 5, 2021 10:12
To: lilypond-user@gnu.org <mailto:lilypond-user@gnu.org>
Subject: Re: Workaround for (not-allowed) numbers in variable names?

I also wondered why numbers are not allowed in variables.
As for me, I used things like A, B, C instead... but it is less
practical.

My guess is that it may be linked to the way numbers are used in
notes and chords to indicate duration, otherwise it would be real
nice to be able to use digits in variable names...!

Le 05.03.21 à 17:37, stefano franchi a écrit :
Here is a question for anyone who may have been using lilypond for
projects involving text and many, many, short and similar musical
snippets.

I am putting together a book that will contain many (very brief)
exercises, grouped thematically. I had thought a convenient and
flexible way to organize the material and keep future maintenance
under control would be to create top level variables names for the
main musical categories and sub-categories and then assign each score
snippet to progressively numbered variable. So I would have, CategA-1
= {"code for one exercise"} , CategB-2 = "code for another
exercise"}, and so on. Clean structure, easy to maintain and
rearrange, etc.

Then I discovered that lilypond does not allow numbers in variable
names :-(

I'd be willing to bet my use case is not particularly weird---there
must have been other people encountering the same problem.

How have you guys managed it?

Cheers,

S.


--
__
Stefano Franchi

stefano.fran...@gmail.com <mailto:stefano.fran...@gmail.com>
https://www.researchgate.net/profile/Stefano_Franchi

--
Silvain Dupertuis
Route de Lausanne 335
1293 Bellevue (Switzerland)
tél. +41-(0)22-774.20.67
portable +41-(0)79-604.87.52
web: silvain-dupertuis.org







Re: Workaround for (not-allowed) numbers in variable names?

2021-03-06 Thread 田村淳
Wow! This is something I’ve been looking for for a long time. Is this 
documented somewhere?

Best regards,

Jun
https://imslp.org/wiki/User:Jun_T <https://imslp.org/wiki/User:Jun_T>

> 2021/03/06 18:09、Richard Shann のメール:
> 
> On Fri, 2021-03-05 at 10:15 -0800, Mogens Lemvig Hansen wrote:
>> I believe it was David K who made this magic work:
>>  
>> \version "2.20.0"
>>  
>> mus.1 = { c d e }
>>  
>> \score {
>>   \new Staff { \mus.1 }
>> }
>>  
> 
> This can be extended to cover the case where a variable has two numbers
> associated with it:
> 
> 8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><
> \version "2.20.0"
>  
> Movement.1.Staff.1 = { c d e }
> Movement.1.Staff.2 = { c' d' e' }
> Movement.2.Staff.1 = { f g a } 
> Movement.2.Staff.2 = { f' g' a' } 
> \score {
>   <<
> \new Staff { \Movement.1.Staff.1 }
> \new Staff { \Movement.1.Staff.2 }
>   >>
> 
> }
> \score {
>   <<
>   \new Staff { \Movement.2.Staff.1 }
> \new Staff { \Movement.2.Staff.2 }
>   >>
> 
> }
> 
> 8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><
> 
> (cautionary note: I haven't examined the code or docs on this, but it
> seems a dot before and after will do the trick mid-word and a single
> dot at end of word)
> 
> A decade or so ago I resorted to converting all the numbers to Roman
> numerals using a C routine that's knocking around on the interweb...
> time I upgraded that.
> 
> Richard Shann
> 
> 
> 
>> Regards,
>> Mogens
>>  
>> From: Silvain Dupertuis
>> Sent: March 5, 2021 10:12
>> To: lilypond-user@gnu.org
>> Subject: Re: Workaround for (not-allowed) numbers in variable names?
>>  
>> I also wondered why numbers are not allowed in variables.
>> As for me, I used things like A, B, C instead... but it is less
>> practical.
>>  
>> My guess is that it may be linked to the way numbers are used in
>> notes and chords to indicate duration, otherwise it would be real
>> nice to be able to use digits in variable names...!
>>  
>> Le 05.03.21 à 17:37, stefano franchi a écrit :
>> Here is a question for anyone who may have been using lilypond for
>> projects involving text and many, many, short and similar musical
>> snippets.
>>  
>> I am putting together a book that will contain many (very brief) 
>> exercises, grouped thematically. I had thought a convenient and
>> flexible way to organize the material and keep future maintenance
>> under control would be to create top level variables names for the
>> main musical categories and sub-categories and then assign each score
>> snippet to progressively numbered variable. So I would have, CategA-1 
>> = {"code for one exercise"} , CategB-2 = "code for another
>> exercise"}, and so on. Clean structure, easy to maintain and
>> rearrange, etc.
>>  
>> Then I discovered that lilypond does not allow numbers in variable
>> names :-(
>>  
>> I'd be willing to bet my use case is not particularly weird---there
>> must have been other people encountering the same problem.
>>  
>> How have you guys managed it?
>>  
>> Cheers,
>>  
>> S.
>>  
>> 
>> --
>> __
>> Stefano Franchi
>> 
>> stefano.fran...@gmail.com
>> https://www.researchgate.net/profile/Stefano_Franchi
>>  
>> -- 
>> Silvain Dupertuis
>> Route de Lausanne 335
>> 1293 Bellevue (Switzerland)
>> tél. +41-(0)22-774.20.67
>> portable +41-(0)79-604.87.52
>> web: silvain-dupertuis.org
>>  
> 



Re: Workaround for (not-allowed) numbers in variable names?

2021-03-06 Thread Richard Shann
On Fri, 2021-03-05 at 10:15 -0800, Mogens Lemvig Hansen wrote:
> I believe it was David K who made this magic work:
>  
> \version "2.20.0"
>  
> mus.1 = { c d e }
>  
> \score {
>   \new Staff { \mus.1 }
> }
>  

This can be extended to cover the case where a variable has two numbers
associated with it:

8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><
\version "2.20.0"
 
Movement.1.Staff.1 = { c d e }
Movement.1.Staff.2 = { c' d' e' }
Movement.2.Staff.1 = { f g a } 
Movement.2.Staff.2 = { f' g' a' } 
\score {
  <<
\new Staff { \Movement.1.Staff.1 }
\new Staff { \Movement.1.Staff.2 }
  >>

}
\score {
  <<
  \new Staff { \Movement.2.Staff.1 }
\new Staff { \Movement.2.Staff.2 }
  >>

}

8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><

(cautionary note: I haven't examined the code or docs on this, but it
seems a dot before and after will do the trick mid-word and a single
dot at end of word)

A decade or so ago I resorted to converting all the numbers to Roman
numerals using a C routine that's knocking around on the interweb...
time I upgraded that.

Richard Shann



> Regards,
> Mogens
>  
> From: Silvain Dupertuis
> Sent: March 5, 2021 10:12
> To: lilypond-user@gnu.org
> Subject: Re: Workaround for (not-allowed) numbers in variable names?
>  
> I also wondered why numbers are not allowed in variables.
> As for me, I used things like A, B, C instead... but it is less
> practical.
>  
> My guess is that it may be linked to the way numbers are used in
> notes and chords to indicate duration, otherwise it would be real
> nice to be able to use digits in variable names...!
>  
> Le 05.03.21 à 17:37, stefano franchi a écrit :
> Here is a question for anyone who may have been using lilypond for
> projects involving text and many, many, short and similar musical
> snippets.
>  
> I am putting together a book that will contain many (very brief) 
> exercises, grouped thematically. I had thought a convenient and
> flexible way to organize the material and keep future maintenance
> under control would be to create top level variables names for the
> main musical categories and sub-categories and then assign each score
> snippet to progressively numbered variable. So I would have, CategA-1 
> = {"code for one exercise"} , CategB-2 = "code for another
> exercise"}, and so on. Clean structure, easy to maintain and
> rearrange, etc.
>  
> Then I discovered that lilypond does not allow numbers in variable
> names :-(
>  
> I'd be willing to bet my use case is not particularly weird---there
> must have been other people encountering the same problem.
>  
> How have you guys managed it?
>  
> Cheers,
>  
> S.
>  
> 
> --
> __
> Stefano Franchi
> 
> stefano.fran...@gmail.com
> https://www.researchgate.net/profile/Stefano_Franchi
>  
> -- 
> Silvain Dupertuis
> Route de Lausanne 335
> 1293 Bellevue (Switzerland)
> tél. +41-(0)22-774.20.67
> portable +41-(0)79-604.87.52
> web: silvain-dupertuis.org
>  



Re: Workaround for (not-allowed) numbers in variable names?

2021-03-05 Thread Silvain Dupertuis


Yes, it works with quotes in the variable definition as well as in the call :

/Exemple/
"gamme1" = \relative c' { g a b c d e f g }
\score { \"gamme1" }

Nice !!

Le 05.03.21 à 18:13, Kenneth Wolcott a écrit :

Thank you for asking (and answering) this question! I always wondered
about this. Now I have a solution which is better than spelling out
numbers.

Ken

On Fri, Mar 5, 2021 at 8:44 AM stefano franchi
 wrote:

Right, so I'm stupid. All it takes is to enclose the variable_with_number names 
in quotes

On Fri, Mar 5, 2021 at 10:37 AM stefano franchi  
wrote:

Here is a question for anyone who may have been using lilypond for projects 
involving text and many, many, short and similar musical snippets.

I am putting together a book that will contain many (very brief)  exercises, grouped thematically. 
I had thought a convenient and flexible way to organize the material and keep future maintenance 
under control would be to create top level variables names for the main musical categories and 
sub-categories and then assign each score snippet to progressively numbered variable. So I would 
have, CategA-1 = {"code for one exercise"} , CategB-2 = "code for another 
exercise"}, and so on. Clean structure, easy to maintain and rearrange, etc.

Then I discovered that lilypond does not allow numbers in variable names :-(

I'd be willing to bet my use case is not particularly weird---there must have 
been other people encountering the same problem.

How have you guys managed it?

Cheers,

S.


--
__
Stefano Franchi

stefano.fran...@gmail.com
https://www.researchgate.net/profile/Stefano_Franchi



--
__
Stefano Franchi

stefano.fran...@gmail.com
https://www.researchgate.net/profile/Stefano_Franchi



--
Silvain Dupertuis
Route de Lausanne 335
1293 Bellevue (Switzerland)
tél. +41-(0)22-774.20.67
portable +41-(0)79-604.87.52
web: silvain-dupertuis.org <http://perso.silvain-dupertuis.org>


Re: Workaround for (not-allowed) numbers in variable names?

2021-03-05 Thread Valentin Petzel
Hello Stefano,

You might try to keep the whole thing dynamic and leave the numbering and 
stuff to Lilypond. For example you could have just a list of all Examples in 
one Category and then have a function to print that out. You could even do a 
list of Categories and print them all at once. This way you could even manage 
your Scores anyway you want, and adding Examples to one Group requires just 
adding it to that list. See the appended File for an example.

Cheers,
ValentincatScore=
#(define-scheme-function (music number) (ly:music? number?)
   #{
 \score {
   \header {
 piece = \markup { Ex. #(number->string number) }
   }
   #music
   \layout { }
 }
   #})

addScore = #(define-void-function (score) (ly:score?) (add-score score)) 

catScores=
#(define-void-function (listOfScores i) (ly:music-list? number?)
   (if (not (null? listOfScores))
   (begin
 (add-score (catScore (car listOfScores) i))
 (catScores (cdr listOfScores) (+ i 1)
 

#(define catA (list
   #{ c'4 e'8 e' g' f' e'4 #}
   #{ d'4 4 16 16 e'8 g' d' #}
   #{ e'8 8 f' f' d' d' g4 #}))


\markup "Only printing one category this time"

\catScores #catA 1

#(define catB (list
   #{ \time 2/3 \times 2/3 { f'4 g' a' e' } #}
   #{ \new StaffGroup <<
 \new Staff { c'8 d' e' f' e' d' c'4 } 
 \new Staff {\clef bass c4 g f e }
   >> #}
   #{  \new TabStaff { e, g b e' } #}))

printCats=
#(define-void-function (listOfCategories) (list?)
   (if (not (null? listOfCategories))
   (begin
 (add-text
  #{
   \markup\larger\larger\larger { Category #(car (car listOfCategories)) }
  #})
 (catScores (cdr (car listOfCategories)) 1)
 (printCats (cdr listOfCategories)

#(define cats (list (cons "A" catA) (cons "B" catB)))

\markup "Printing all categories"

\printCats #cats

testm =\markup "test"
#(display testm)

signature.asc
Description: This is a digitally signed message part.


Re: Workaround for (not-allowed) numbers in variable names?

2021-03-05 Thread Tom Brennan
That's neat. I checked to see that unicode as well as whitespace seems to
work via quoting, too.

\version "2.22"
"rødgrød med fløde 123
和毛泽东 <<重上井冈山>>. 严永欣, 一九八八年.

久有归天愿
终过鬼门关
千里来寻归宿
春华变苍颜
到处群魔乱舞
更有妖雾盘绕
暗道入阴间
过了阎王殿
险处不须看

风雷动
旌旗奋
忆人寰
八十三年过去
弹指一挥间
中原千军逐蒋
城楼万众检阅
褒贬满载还
世上无难事
只怕我癫痫
" = { a b c }

clarinet = \new Voice {
\"rødgrød med fløde 123
和毛泽东 <<重上井冈山>>. 严永欣, 一九八八年.

久有归天愿
终过鬼门关
千里来寻归宿
春华变苍颜
到处群魔乱舞
更有妖雾盘绕
暗道入阴间
过了阎王殿
险处不须看

风雷动
旌旗奋
忆人寰
八十三年过去
弹指一挥间
中原千军逐蒋
城楼万众检阅
褒贬满载还
世上无难事
只怕我癫痫
"
}



On Fri, Mar 5, 2021, 11:45 stefano franchi 
wrote:
>
> Right, so I'm stupid. All it takes is to enclose the variable_with_number
names in quotes
>
> On Fri, Mar 5, 2021 at 10:37 AM stefano franchi 
wrote:
>>
>> Here is a question for anyone who may have been using lilypond for
projects involving text and many, many, short and similar musical snippets.
>>
>> I am putting together a book that will contain many (very brief)
 exercises, grouped thematically. I had thought a convenient and flexible
way to organize the material and keep future maintenance under control
would be to create top level variables names for the main musical
categories and sub-categories and then assign each score snippet to
progressively numbered variable. So I would have, CategA-1 = {"code for one
exercise"} , CategB-2 = "code for another exercise"}, and so on. Clean
structure, easy to maintain and rearrange, etc.
>>
>> Then I discovered that lilypond does not allow numbers in variable
names :-(
>>
>> I'd be willing to bet my use case is not particularly weird---there must
have been other people encountering the same problem.
>>
>> How have you guys managed it?
>>
>> Cheers,
>>
>> S.
>>
>>
>> --
>> __
>> Stefano Franchi
>>
>> stefano.fran...@gmail.com
>> https://www.researchgate.net/profile/Stefano_Franchi
>
>
>
> --
> __
> Stefano Franchi
>
> stefano.fran...@gmail.com
> https://www.researchgate.net/profile/Stefano_Franchi

>


RE: Workaround for (not-allowed) numbers in variable names?

2021-03-05 Thread Mogens Lemvig Hansen
I believe it was David K who made this magic work:

\version "2.20.0"

mus.1 = { c d e }

\score {
  \new Staff { \mus.1 }
}

Regards,
Mogens

From: Silvain Dupertuis
Sent: March 5, 2021 10:12
To: lilypond-user@gnu.org
Subject: Re: Workaround for (not-allowed) numbers in variable names?

I also wondered why numbers are not allowed in variables.
As for me, I used things like A, B, C instead... but it is less practical.

My guess is that it may be linked to the way numbers are used in notes and 
chords to indicate duration, otherwise it would be real nice to be able to use 
digits in variable names...!

Le 05.03.21 à 17:37, stefano franchi a écrit :
Here is a question for anyone who may have been using lilypond for projects 
involving text and many, many, short and similar musical snippets.

I am putting together a book that will contain many (very brief)  exercises, 
grouped thematically. I had thought a convenient and flexible way to organize 
the material and keep future maintenance under control would be to create top 
level variables names for the main musical categories and sub-categories and 
then assign each score snippet to progressively numbered variable. So I would 
have, CategA-1 = {"code for one exercise"} , CategB-2 = "code for another 
exercise"}, and so on. Clean structure, easy to maintain and rearrange, etc.

Then I discovered that lilypond does not allow numbers in variable names :-(

I'd be willing to bet my use case is not particularly weird---there must have 
been other people encountering the same problem.

How have you guys managed it?

Cheers,

S.


-- 
__
Stefano Franchi

stefano.fran...@gmail.com
https://www.researchgate.net/profile/Stefano_Franchi

-- 
Silvain Dupertuis
Route de Lausanne 335
1293 Bellevue (Switzerland)
tél. +41-(0)22-774.20.67
portable +41-(0)79-604.87.52
web: silvain-dupertuis.org



Re: Workaround for (not-allowed) numbers in variable names?

2021-03-05 Thread Silvain Dupertuis

I also wondered why numbers are not allowed in variables.
As for me, I used things like A, B, C instead... but it is less practical.

My guess is that it may be linked to the way numbers are used in notes and chords to 
indicate duration, otherwise it would be real nice to be able to use digits in variable 
names...!


Le 05.03.21 à 17:37, stefano franchi a écrit :
Here is a question for anyone who may have been using lilypond for projects involving 
text and many, many, short and similar musical snippets.


I am putting together a book that will contain many (very brief)  exercises, grouped 
thematically. I had thought a convenient and flexible way to organize the material and 
keep future maintenance under control would be to create top level variables names for 
the main musical categories and sub-categories and then assign each score snippet to 
progressively numbered variable. So I would have, CategA-1 = {"code for one exercise"} , 
CategB-2 = "code for another exercise"}, and so on. Clean structure, easy to maintain 
and rearrange, etc.


Then I discovered that lilypond does not allow numbers in variable names :-(

I'd be willing to bet my use case is not particularly weird---there must have been other 
people encountering the same problem.


How have you guys managed it?

Cheers,

S.


--
__
Stefano Franchi

stefano.fran...@gmail.com <mailto:stef...@tamu.edu>
/https://www.researchgate.net/profile/Stefano_Franchi/ 
<https://www.researchgate.net/profile/Stefano_Franchi>



--
Silvain Dupertuis
Route de Lausanne 335
1293 Bellevue (Switzerland)
tél. +41-(0)22-774.20.67
portable +41-(0)79-604.87.52
web: silvain-dupertuis.org <http://perso.silvain-dupertuis.org>


Re: Workaround for (not-allowed) numbers in variable names?

2021-03-05 Thread Kenneth Wolcott
Thank you for asking (and answering) this question! I always wondered
about this. Now I have a solution which is better than spelling out
numbers.

Ken

On Fri, Mar 5, 2021 at 8:44 AM stefano franchi
 wrote:
>
> Right, so I'm stupid. All it takes is to enclose the variable_with_number 
> names in quotes
>
> On Fri, Mar 5, 2021 at 10:37 AM stefano franchi  
> wrote:
>>
>> Here is a question for anyone who may have been using lilypond for projects 
>> involving text and many, many, short and similar musical snippets.
>>
>> I am putting together a book that will contain many (very brief)  exercises, 
>> grouped thematically. I had thought a convenient and flexible way to 
>> organize the material and keep future maintenance under control would be to 
>> create top level variables names for the main musical categories and 
>> sub-categories and then assign each score snippet to progressively numbered 
>> variable. So I would have, CategA-1 = {"code for one exercise"} , CategB-2 = 
>> "code for another exercise"}, and so on. Clean structure, easy to maintain 
>> and rearrange, etc.
>>
>> Then I discovered that lilypond does not allow numbers in variable names 
>> :-(
>>
>> I'd be willing to bet my use case is not particularly weird---there must 
>> have been other people encountering the same problem.
>>
>> How have you guys managed it?
>>
>> Cheers,
>>
>> S.
>>
>>
>> --
>> __
>> Stefano Franchi
>>
>> stefano.fran...@gmail.com
>> https://www.researchgate.net/profile/Stefano_Franchi
>
>
>
> --
> __
> Stefano Franchi
>
> stefano.fran...@gmail.com
> https://www.researchgate.net/profile/Stefano_Franchi



Re: Workaround for (not-allowed) numbers in variable names?

2021-03-05 Thread stefano franchi
Right, so I'm stupid. All it takes is to enclose the variable_with_number
names in quotes

On Fri, Mar 5, 2021 at 10:37 AM stefano franchi 
wrote:

> Here is a question for anyone who may have been using lilypond for
> projects involving text and many, many, short and similar musical snippets.
>
> I am putting together a book that will contain many (very brief)
> exercises, grouped thematically. I had thought a convenient and flexible
> way to organize the material and keep future maintenance under control
> would be to create top level variables names for the main musical
> categories and sub-categories and then assign each score snippet to
> progressively numbered variable. So I would have, CategA-1 = {"code for one
> exercise"} , CategB-2 = "code for another exercise"}, and so on. Clean
> structure, easy to maintain and rearrange, etc.
>
> Then I discovered that lilypond does not allow numbers in variable
> names :-(
>
> I'd be willing to bet my use case is not particularly weird---there must
> have been other people encountering the same problem.
>
> How have you guys managed it?
>
> Cheers,
>
> S.
>
>
> --
> __
> Stefano Franchi
>
> stefano.fran...@gmail.com 
> *https://www.researchgate.net/profile/Stefano_Franchi*
> <https://www.researchgate.net/profile/Stefano_Franchi>
>


-- 
__
Stefano Franchi

stefano.fran...@gmail.com 
*https://www.researchgate.net/profile/Stefano_Franchi*
<https://www.researchgate.net/profile/Stefano_Franchi>


Workaround for (not-allowed) numbers in variable names?

2021-03-05 Thread stefano franchi
Here is a question for anyone who may have been using lilypond for projects
involving text and many, many, short and similar musical snippets.

I am putting together a book that will contain many (very brief)
exercises, grouped thematically. I had thought a convenient and flexible
way to organize the material and keep future maintenance under control
would be to create top level variables names for the main musical
categories and sub-categories and then assign each score snippet to
progressively numbered variable. So I would have, CategA-1 = {"code for one
exercise"} , CategB-2 = "code for another exercise"}, and so on. Clean
structure, easy to maintain and rearrange, etc.

Then I discovered that lilypond does not allow numbers in variable
names :-(

I'd be willing to bet my use case is not particularly weird---there must
have been other people encountering the same problem.

How have you guys managed it?

Cheers,

S.


-- 
__
Stefano Franchi

stefano.fran...@gmail.com 
*https://www.researchgate.net/profile/Stefano_Franchi*
<https://www.researchgate.net/profile/Stefano_Franchi>


Re: Numbers in variable names Re: thoughts

2007-01-02 Thread Mats Bengtsson

For example, you can define your own music function that has a single
numerical argument (for example to modify some spacing parameters).
The syntax for such a function would be exacty of the form \myvar 1.

  /Mats

[EMAIL PROTECTED] wrote:

I would expect that
   \myvar1  refers to the variable myvar1
   \myvar 1 refers to the var myvar followed by 1



As regards the expression
  \myvar 1
in what context do you use that?
  




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


Numbers in variable names Re: thoughts

2007-01-01 Thread Andrew Black - lists

Han-Wen Nienhuys wrote:



  c4_\staccato_\markup { bla }

does this reference \staccato or \staccato_ ?

It might be possible to enable numbers, though.  I would welcome an analysis.


I would really like to see numbers in name of variables.
I am not expert on parsers so apologies if this is hard but...

If you have
 myvar = something
 myvar1 = something else
I would expect that
  \myvar1  refers to the variable myvar1
  \myvar 1 refers to the var myvar followed by 1



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


Numbers in variable names Re: thoughts

2007-01-01 Thread stk

 I would expect that
\myvar1  refers to the variable myvar1
\myvar 1 refers to the var myvar followed by 1

As regards the expression
  \myvar 1
in what context do you use that?

-- Tom



Andrew Black wrote:

I would really like to see numbers in name of variables.
I am not expert on parsers so apologies if this is hard but...

If you have
  myvar = something
  myvar1 = something else
I would expect that
   \myvar1  refers to the variable myvar1
   \myvar 1 refers to the var myvar followed by 1



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


numbers in variable names

2006-04-19 Thread Kieren Richard MacMillan

Hello, all --

I use a lot of variables, especially when breaking larger works  
across multiple pieces (and thus .ly files).


I'd like to name my variables numerically, e.g.,

file01.ly
global01 = { ... }
notes01 = { ... }

file02.ly
global02 = { ... }
notes02 = { ... }

score.ly
\score {  \global01 \notes01  }
\markup { splitter text }
\score {  \global02 \notes02   }

but Lilypond (more likely LaTeX) won't let me. Does anyone know a  
workaround?


Thanks,
Kieren.


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


Re: numbers in variable names

2006-04-19 Thread Daniel Johnson

Kieren Richard MacMillan wrote:

Hello, all --

I use a lot of variables, especially when breaking larger works across 
multiple pieces (and thus .ly files).

snip
but Lilypond (more likely LaTeX) won't let me. Does anyone know a 
workaround?

I always use Roman numerals.
grin


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


Re: numbers in variable names

2006-04-19 Thread Geoff Horton
  but Lilypond (more likely LaTeX) won't let me. Does anyone know a
  workaround?

It's LilyPond. LaTeX isn't even used anymore. Roman numerals or
spelling out the numbers ( \globalZeroOne ) are the only ways I know
to work around it.

Geoff


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


Re: numbers in variable names

2006-04-19 Thread andrea valle

On 19 Apr 2006, at 19:19, Daniel Johnson wrote:



I always use Roman numerals.



Interesting, I understand perfectly the weltanschauung behind the 
technique.  Dadaism is the next step.
In fact, I automatically convert numbers in letters with a hash table, 
so you have this Picabian-style

variable names:

voice152 = voicebec
voice065 = voiceafe

and so on...

This contaminates also my conTeXt files.

(sorry, I guess it won't help..)

-a-









grin


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



Andrea Valle
DAMS - Facoltà di Scienze della Formazione
Università degli Studi di Torino
http://www.semiotiche.it/andrea
[EMAIL PROTECTED]



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