Substitution function syntax

Making a function that substitutes a variable into LilyPond code is easy. The general form of these functions is

function =
     (arg1 arg2 …)
     (type1? type2? …)


argNThe nth argument.
typeN?A Scheme type predicate for which argN must return #t.
…music…Normal LilyPond input, using ‘$’ (in places where only LilyPond constructs are allowed) or ‘#’ (to use it as a Scheme value or music function argument or music inside of music lists) to reference arguments (e.g., ‘#arg1’).

The list of type predicates is required. Some of the most common type predicates used in music functions are:

For a list of available type predicates, see Predefined type predicates. User-defined type predicates are also allowed.

See also

Notation Reference: Predefined type predicates.

Extending LilyPond: Music functions.

Installed Files: lily/, scm/c++.scm, scm/lily.scm.

LilyPond Notation Reference v2.25.16 (development-branch).