lilypond-user
[Top][All Lists]
Advanced

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

Re: Detecting null markup in Scheme


From: David Kastrup
Subject: Re: Detecting null markup in Scheme
Date: Fri, 01 Sep 2017 19:06:21 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

Graham King <address@hidden> writes:

> I have a monstrous music-function that constructs a markup in Scheme and
> then decides whether to put it at system-level or staff-level, along the
> following lines (much-redacted):
>
> foo = #(define-music-function (args...) (types...)
>   (let* ((markupContents #{
>             \markup {
>                \concat {
>                   #markupOne 
>                   #markupTwo
>                }}
>         #})
>   (case whereMarkup
>      ((system) #{ \mark #markupContents #})
>      ((staff)  #{ <>^   #markupContents #})
>      (else     #{ \mark \markup \color #red #markupContents #})
>   ))
> )
>
> The problem is: how best to deal with the case where #markone and
> #markuptwo are both empty, i.e. #{ \markup "" #}, and no markup at all
> should be attempted?
>
> I've tried variations on:
>   ( if ( string=? ( markup->string markupContents ) 
>                   ( markup->string empty-markup ))
>          (#{ <> #})
>          (case whereMarkup ...
>
> but my grasp of Scheme, never very firm, is slipping away.
>
> Grateful for any suggestions, pointers to documentation/tutorials,
> etc.

I'd just try (equal? markupContents "") here.  equal? can compare any
objects for "equality", and at least "" as input should compare equal
then.

-- 
David Kastrup



reply via email to

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