Re: Is it possible to replace a number with variable inside a pair?
Jan-Peter Voigt writes: > Hi Risto, > > you might go this way: > > lineThickness = 5 > \markup \override #`(thickness . ,lineThickness) \draw-hline > > That is semi-quote the pair with ` (instead of ') and then "unquote" the > variable to retrieve the value with a comma (,) Which is equivalent to \markup \override #(cons 'thickness lineThickness) \draw-hline Either will create a pair at "runtime" rather than directly in the "Scheme reader" which does not access variables but rather creates symbols when given an identifier. -- David Kastrup ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Is it possible to replace a number with variable inside a pair?
Whoa! I would have never found that out by myself. :) Thanks Urs & Jan-Peter. I have to check the Scheme link, too. BR, Risto On 26 July 2018 at 10:40, Jan-Peter Voigt wrote: > Hi Risto, > > you might go this way: > > lineThickness = 5 > \markup \override #`(thickness . ,lineThickness) \draw-hline > > That is semi-quote the pair with ` (instead of ') and then "unquote" the > variable to retrieve the value with a comma (,) > > HTH > Jan-Peter > > Am 26.07.2018 um 09:35 schrieb Risto Vääräniemi: > > Hi, > > > > I tried the following: > > > > lineThickness = 5 > > \markup \override #'(thickness . #lineThickness) \draw-hline > > > > But it seems I cannot give the variable inside the pair. This works: > > > > lineThicknessPair = #'(thickness . 5) > > \markup \override #lineThicknessPair \draw-hline > > > > Is there any way to make it work with just a single number variable? I > > even tried the variable without the '#' or replaced it with a '\'. I > > just got different errors. > > > > BR, > > Risto > > > > > > ___ > > lilypond-user mailing list > > lilypond-user@gnu.org > > https://lists.gnu.org/mailman/listinfo/lilypond-user > > > > > ___ > lilypond-user mailing list > lilypond-user@gnu.org > https://lists.gnu.org/mailman/listinfo/lilypond-user > ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Is it possible to replace a number with variable inside a pair?
Hi Risto, you might go this way: lineThickness = 5 \markup \override #`(thickness . ,lineThickness) \draw-hline That is semi-quote the pair with ` (instead of ') and then "unquote" the variable to retrieve the value with a comma (,) HTH Jan-Peter Am 26.07.2018 um 09:35 schrieb Risto Vääräniemi: > Hi, > > I tried the following: > > lineThickness = 5 > \markup \override #'(thickness . #lineThickness) \draw-hline > > But it seems I cannot give the variable inside the pair. This works: > > lineThicknessPair = #'(thickness . 5) > \markup \override #lineThicknessPair \draw-hline > > Is there any way to make it work with just a single number variable? I > even tried the variable without the '#' or replaced it with a '\'. I > just got different errors. > > BR, > Risto > > > ___ > lilypond-user mailing list > lilypond-user@gnu.org > https://lists.gnu.org/mailman/listinfo/lilypond-user > ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Is it possible to replace a number with variable inside a pair?
Am 26.07.2018 um 09:35 schrieb Risto Vääräniemi: Hi, I tried the following: lineThickness = 5 \markup \override #'(thickness . #lineThickness) \draw-hline But it seems I cannot give the variable inside the pair. This works: lineThicknessPair = #'(thickness . 5) \markup \override #lineThicknessPair \draw-hline Is there any way to make it work with just a single number variable? I even tried the variable without the '#' or replaced it with a '\'. I just got different errors. You need a technique known as quasi-quoting. In your code #'( means that you have a pair of literal symbols, i.e. a symbol "thickness" and a symbol "#lineThickness". The straight single quote tells Lily to "quote" everything inside the brackets. What you need is to write the pair as #`(a . b) with a backtick instead of a straight single quote. This allows you to "unquote" individual elements with a comma: lineThickness = 5 \markup \override #`(thickness . ,lineThickness) \draw-hline See https://scheme-book.ursliska.de/scheme/quoting/ for some more info HTH Urs BR, Risto ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Is it possible to replace a number with variable inside a pair?
Hi, I tried the following: lineThickness = 5 \markup \override #'(thickness . #lineThickness) \draw-hline But it seems I cannot give the variable inside the pair. This works: lineThicknessPair = #'(thickness . 5) \markup \override #lineThicknessPair \draw-hline Is there any way to make it work with just a single number variable? I even tried the variable without the '#' or replaced it with a '\'. I just got different errors. BR, Risto ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user