lilypond-user
[Top][All Lists]
Advanced

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

Re: Scheme coding: 'number' cases vs 'string' cases


From: tisimst
Subject: Re: Scheme coding: 'number' cases vs 'string' cases
Date: Thu, 9 Apr 2015 10:48:50 -0700 (MST)

Pierre,

Following Paul's advice, here's working code (which you probably already figured out, but just for the record). Note that you must use equal? for comparisons since it's the only one suited for strings:

%<---------- SNIP ----------

#(define-markup-command (smiley-string layout props smiley-choice) 
  (string?)
  (interpret-markup layout props
    (cond
      ((equal? smiley-choice "A") 
        #{
           \markup "A"
        #})
      ((equal? smiley-choice ":)") 
        #{
           \markup "smile"
        #})
      (else 
        #{
           \markup
           \null
        #})
      )))

%% Test:
\markup\column {
  \smiley-string #"A"
  \smiley-string #":)"
  \smiley-string #"none"
}

%<---------- SNIP ----------

- Abraham

On Thu, Apr 9, 2015 at 11:40 AM, Paul Morris [via Lilypond] <[hidden email]> wrote:
Schneidy wrote
What am I missing?
Hi Pierre,

case doesn't work with strings, so you'd need to use cond instead.

Cheers,
-Paul


If you reply to this email, your message will be added to the discussion below:
http://lilypond.1069038.n5.nabble.com/Scheme-coding-number-cases-vs-string-cases-tp174287p174294.html
To start a new topic under User, email [hidden email]
To unsubscribe from Lilypond, click here.
NAML



View this message in context: Re: Scheme coding: 'number' cases vs 'string' cases
Sent from the User mailing list archive at Nabble.com.

reply via email to

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