lilypond-user
[Top][All Lists]
Advanced

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

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


From: Pierre Perol-Schneider
Subject: Scheme coding: 'number' cases vs 'string' cases
Date: Thu, 9 Apr 2015 18:36:36 +0200

Hi List, hi Schemers,

I'm currently working on finding new tools to ease drawings with the 'path' command.
I already found some nice ones that helped me to create new drawings and enhanced old snippets.
That's what I've done here: http://lsr.di.unimi.it/LSR/Item?id=904

However, I'm not satisfied with the code I'm using there; here's roughly how it's working:

\version "2.18.2"

%% hereunder works fine:
#(define-markup-command (smiley layout props smiley-choice)
  (number?)
  (interpret-markup layout props
    (case smiley-choice
      ((1)
        #{
           \markup "A"
        #})
      ((2)
        #{
           \markup "smile"
        #})
      (else
        #{
           \markup
           \null
        #})
      )))

%% Test:
\markup\column {
  \smiley #1
  \smiley #2
  \smiley #10
}

%% But I think It would be much better to use:
#(define-markup-command (smiley-string layout props smiley-choice)
  (string?)
  (interpret-markup layout props
    (case smiley-choice
      (("A")
        #{
           \markup "A"
        #})
      ((":)")
        #{
           \markup "smile"
        #})
      (else
        #{
           \markup
           \null
        #})
      )))

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

%%% ... does not work though.

What am I missing?

Thank you in advance,
Cheers,
Pierre



reply via email to

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