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