Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1173)

Unified Diff: scm/lily-library.scm

Issue 145490043: Roman string numbers (Closed)
Patch Set: Define a separate number-interface Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « scm/fret-diagrams.scm ('k') | scm/output-lib.scm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scm/lily-library.scm
diff --git a/scm/lily-library.scm b/scm/lily-library.scm
index 472a82da24c4a785a5ef6c267f48f25327773d8c..9008831c722316ad8b45ed8835c0457548d66a69 100644
--- a/scm/lily-library.scm
+++ b/scm/lily-library.scm
@@ -889,6 +889,26 @@ Handy for debugging, possibly turned off."
(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))))
+
;;;;;;;;;;;;;;;;
;; other
« no previous file with comments | « scm/fret-diagrams.scm ('k') | scm/output-lib.scm » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b