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…
HTH, Simon
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user