lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scheme help request: How can else of an if-statement be made to do n


From: Matthew Fong
Subject: Re: Scheme help request: How can else of an if-statement be made to do nothing?
Date: Fri, 11 Dec 2020 10:43:38 -0800

Hello everyone,

Resurrecting an old thread. I've been trying my hand in Scheme programming, via small examples on the project I'm working on.

I wanted to extend the variable list to this function Harm wrote, to take an extra boolean variable, which is pretty trivial. The boolean is meant to change the color of the text depending if it's true or false. But I am not clear on how to define the color using the boolean. The trivial way to do it is adding a conditional under the first if, and duplicate all the code except the color. Is there a proper Scheme-ish way to do this? (Admittingly, I have not caught on to Scheme just yet -- my brain tends to work with Python)

print-if-defined =
#(define-void-function (sym text) (symbol? markup?)
  (if (defined? sym)
      (add-text #{ \markup \with-color #'(0.8 0.2 0.2) #text #})))

symA = "Something"

\print-if-defined #'symB "Text"
\print-if-defined #'symA "Text"


Many thanks,
mattfong

reply via email to

[Prev in Thread] Current Thread [Next in Thread]