+ (reverse matches))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; numbering styles
+
+(define-public (number-format number-type num . custom-format)
+ "Print NUM accordingly to the requested NUMBER-TYPE.
+Choices include @code{roman-lower} (by default),
+@code{roman-upper}, @code{arabic} and @code{custom}.
+In the latter case, CUSTOM-FORMAT must be supplied
+and will be applied to NUM."
+ (cond
+ ((equal? number-type 'roman-lower)
+ (fancy-format #f "~(~@r~)" num))
+ ((equal? number-type 'roman-upper)
+ (fancy-format #f "~@r" num))
+ ((equal? number-type 'arabic)
+ (fancy-format #f "~d" num))
+ ((equal? number-type 'custom)
+ (fancy-format #f (car custom-format) num))
+ (else (fancy-format #f "~(~@r~)" num))))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; lilypond version
+
+(define (lexicographic-list-compare? op a b)
+ "Lexicographically compare two lists @var{a} and @var{b} using
+ the operator @var{op}. The types of the list elements have to
+ be comparable with @var{op}. If the lists are of different length
+ the trailing elements of the longer list are ignored."
+ (let* ((ca (car a))
+ (iseql (op ca ca)))
+ (let loop ((ca ca) (cb (car b)) (a (cdr a)) (b (cdr b)))
+ (let ((axb (op ca cb)))
+ (if (and (pair? a) (pair? b)
+ (eq? axb iseql (op cb ca)))
+ (loop (car a) (car b) (cdr a) (cdr b))
+ axb)))))
+
+(define (ly:version? op ver)
+ "Using the operator @var{op} compare the currently executed LilyPond
+ version with a given version @var{ver} which is passed as a list of
+ numbers."
+ (lexicographic-list-compare? op (ly:version) ver))