lilypond-user
[Top][All Lists]
Advanced

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

Re: Defining new Scheme predicates


From: Simon Albrecht
Subject: Re: Defining new Scheme predicates
Date: Mon, 7 Nov 2016 01:13:26 +0100

On 07.11.2016 01:12, Simon Albrecht wrote:
On 07.11.2016 01:07, Andrew Bernard wrote:

Greetings All,

In lilypond, if I wanted to define a Scheme predicate such as side? to check whether an argument passed matches only ’left or ’right, how would one go about it?

Looking in lily.scm I see lists of lilypond specific predicates, but it is unclear to me how to create my own additions, and indeed, how they would be implemented (apart from the trivial function itself).

So for example, we have a function

someFunction =

#(define-music-function (thing position)

(number? side?)

…)

How to add such a predicate? Can you, without going under the hood?


Of course you can, and quite easily:

someFunction =
#(let
  ((side? (lambda (foo) (or (equal 'left foo) (equal 'right foo)))))
  (define-music-function (thing position)
        (number? side?)
        …)

TBH, I just wrote that code right here and didn’t test it – but it should be fine…
Except for the missing ) at the end – but you get the idea :-)

HTH, Simon

_______________________________________________
lilypond-user mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/lilypond-user




reply via email to

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