]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 3580: Replace unwarranted uses of map with for-each and other Scheme cleanups
authorDavid Kastrup <dak@gnu.org>
Tue, 24 Sep 2013 14:40:02 +0000 (16:40 +0200)
committerDavid Kastrup <dak@gnu.org>
Tue, 1 Oct 2013 05:47:40 +0000 (07:47 +0200)
Note that some uses of map actually relied on execution order (namely
expecting map to behave like map-in-order) and thus were not just
inelegant because of the side effect.  There are also some other
mostly trivial simplification of Scheme constructs.

41 files changed:
input/regression/tie-chord.ly
ly/init.ly
scm/backend-library.scm
scm/bar-line.scm
scm/chord-generic-names.scm
scm/chord-ignatzek-names.scm
scm/define-grobs.scm
scm/define-markup-commands.scm
scm/define-note-names.scm
scm/define-stencil-commands.scm
scm/define-woodwind-diagrams.scm
scm/display-woodwind-diagrams.scm
scm/document-backend.scm
scm/document-context-mods.scm
scm/document-functions.scm
scm/document-identifiers.scm
scm/document-markup.scm
scm/document-music.scm
scm/document-translation.scm
scm/document-type-predicates.scm
scm/documentation-generate.scm
scm/documentation-lib.scm
scm/font.scm
scm/framework-ps.scm
scm/lily-library.scm
scm/lily.scm
scm/modal-transforms.scm
scm/music-functions.scm
scm/output-lib.scm
scm/output-svg.scm
scm/page.scm
scm/parser-clef.scm
scm/part-combiner.scm
scm/ps-to-png.scm
scm/safe-lily.scm
scm/song-util.scm
scm/stencil.scm
scm/tablature.scm
scm/time-signature-settings.scm
scm/to-xml.scm
scm/translation-functions.scm

index d830bd01a9d98c4c3a51389ff806e9e264239b22..af3ec740a9c0f26e4216f6fd72f1c9d11b78ab5a 100644 (file)
@@ -55,8 +55,8 @@ translate x y z to x~x y~y z~z
 
       (list ch1 ch2)))
 
-  (make-music 'SequentialMusic 'elements (apply append
-                                               (map chord->tied-chord (ly:music-property  chords 'elements)))))
+  (make-music 'SequentialMusic 'elements (append-map
+                                         chord->tied-chord (ly:music-property  chords 'elements))))
 
 baseChords =
 \applyMusic #(lambda (mus)
index 7dbb1042aaea642228b2ec8de27d381078331b5e..acaa2c9899939af19c94e387ff6a9446e773469d 100644 (file)
@@ -55,15 +55,15 @@ $(if (ly:get-option 'include-settings)
                          toplevel-book-handler)))
    (cond ((pair? toplevel-bookparts)
           (let ((book (ly:make-book $defaultpaper $defaultheader)))
-            (map (lambda (part)
-                   (ly:book-add-bookpart! book part))
-                 (reverse! toplevel-bookparts))
+            (for-each (lambda (part)
+                        (ly:book-add-bookpart! book part))
+                      (reverse! toplevel-bookparts))
             (set! toplevel-bookparts (list))
             ;; if scores have been defined after the last explicit \bookpart:
             (if (pair? toplevel-scores)
-                (map (lambda (score)
-                       (ly:book-add-score! book score))
-                     (reverse! toplevel-scores)))
+                (for-each (lambda (score)
+                            (ly:book-add-score! book score))
+                          (reverse! toplevel-scores)))
             (set! toplevel-scores (list))
             (book-handler parser book)))
          ((or (pair? toplevel-scores) output-empty-score-list)
index 7f357376a37a88dfbb18f57c2716b2f16ab23685..a16771818722a57e24cabbba1bc25ea5ef452357 100644 (file)
 
 (define-public (output-scopes scopes fields basename)
   (define (output-scope scope)
-    (apply
-     string-append
+    (string-concatenate
      (module-map
       (lambda (sym var)
         (let ((val (if (variable-bound? var) (variable-ref var) "")))
               (header-to-file basename sym val))
           ""))
       scope)))
-  (apply string-append (map output-scope scopes)))
+  (string-concatenate (map output-scope scopes)))
 
 (define-public (relevant-book-systems book)
   (let ((systems (ly:paper-book-systems book)))
       (ly:warning (_ "missing stencil expression `~S'") name)
       ""))
 
-  (map (lambda (x)
-         (if (not (module-defined? output-module x))
-             (begin
-               (module-define! output-module x
-                               (lambda* (#:optional y . z)
-                                        (missing-stencil-expression x)))
-               (set! missing-stencil-list (append (list x)
-                                                  missing-stencil-list)))))
-       (ly:all-stencil-commands)))
+  (for-each (lambda (x)
+              (if (not (module-defined? output-module x))
+                  (begin
+                    (module-define! output-module x
+                                    (lambda* (#:optional y . z)
+                                             (missing-stencil-expression x)))
+                    (set! missing-stencil-list (cons x missing-stencil-list)))))
+            (ly:all-stencil-commands)))
 
 (define-public (remove-stencil-warnings output-module)
   (for-each
@@ -269,5 +267,5 @@ definition."
         (define-pango-pf pango-pf font-name scaling)))
 
     (string-append
-     (apply string-append (map font-load-command other-fonts))
-     (apply string-append (map pango-font-load-command pango-only-fonts)))))
+     (string-concatenate (map font-load-command other-fonts))
+     (string-concatenate (map pango-font-load-command pango-only-fonts)))))
index fedd21be9a750701645c9d0d063e61d420ac43a3..03c6f808156f88816b7fa6da999670b4b2891316 100644 (file)
@@ -88,10 +88,10 @@ Pad the string with @code{annotation-char}s to the length of the
     (if (pair? line-pos)
         (begin
           (set! iv (cons (car line-pos) (car line-pos)))
-          (map (lambda (x)
-                 (set! iv (cons (min (car iv) x)
-                                (max (cdr iv) x))))
-               (cdr line-pos)))
+          (for-each (lambda (x)
+                      (set! iv (cons (min (car iv) x)
+                                     (max (cdr iv) x))))
+                    (cdr line-pos)))
 
         (let ((line-count (ly:grob-property grob 'line-count 0)))
 
@@ -179,18 +179,18 @@ annotation char from string @var{str}."
          (last-pos (1- (length sorted-elts)))
          (idx 0))
 
-    (map (lambda (g)
-           (ly:grob-set-property!
-            g
-            'has-span-bar
-            (cons (if (eq? idx last-pos)
-                      #f
-                      grob)
-                  (if (zero? idx)
-                      #f
-                      grob)))
-           (set! idx (1+ idx)))
-         sorted-elts)))
+    (for-each (lambda (g)
+                (ly:grob-set-property!
+                 g
+                 'has-span-bar
+                 (cons (if (eq? idx last-pos)
+                           #f
+                           grob)
+                       (if (zero? idx)
+                           #f
+                           grob)))
+                (set! idx (1+ idx)))
+              sorted-elts)))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Line break decisions.
@@ -400,21 +400,21 @@ is not used within the routine."
               (half-thick (/ line-thickness 2.0))
               (stencil empty-stencil))
 
-          (map (lambda (i)
-                 (let ((top-y (min (* (+ i dash-size) half-space)
-                                   (+ (* (1- line-count) half-space)
-                                      half-thick)))
-                       (bot-y (max (* (- i dash-size) half-space)
-                                   (- 0 (* (1- line-count) half-space)
-                                      half-thick))))
-
-                   (set! stencil
-                         (ly:stencil-add
-                          stencil
-                          (ly:round-filled-box (cons 0 thickness)
-                                               (cons bot-y top-y)
-                                               blot)))))
-               (iota line-count (1- line-count) (- 2)))
+          (for-each (lambda (i)
+                      (let ((top-y (min (* (+ i dash-size) half-space)
+                                        (+ (* (1- line-count) half-space)
+                                           half-thick)))
+                            (bot-y (max (* (- i dash-size) half-space)
+                                        (- 0 (* (1- line-count) half-space)
+                                           half-thick))))
+
+                        (set! stencil
+                              (ly:stencil-add
+                               stencil
+                               (ly:round-filled-box (cons 0 thickness)
+                                                    (cons bot-y top-y)
+                                                    blot)))))
+                    (iota line-count (1- line-count) (- 2)))
           stencil)
         (let* ((dashes (/ height staff-space))
                (total-dash-size (/ height dashes))
@@ -823,26 +823,26 @@ no elements."
           ;; we compute the extents of each system and store them
           ;; in a list; dito for the 'allow-span-bar property.
           ;; model-bar takes the bar grob, if given.
-          (map (lambda (bar)
-                 (let ((ext (bar-line::bar-y-extent bar refp))
-                       (staff-symbol (ly:grob-object bar 'staff-symbol)))
-
-                   (if (ly:grob? staff-symbol)
-                       (let ((refp-extent (ly:grob-extent staff-symbol refp Y)))
-
-                         (set! ext (interval-union ext refp-extent))
-
-                         (if (> (interval-length ext) 0)
-                             (begin
-                               (set! extents (append extents (list ext)))
-                               (set! model-bar bar)
-                               (set! make-span-bars
-                                     (append make-span-bars
-                                             (list (ly:grob-property
-                                                    bar
-                                                    'allow-span-bar
-                                                    #t))))))))))
-               elts)
+          (for-each (lambda (bar)
+                      (let ((ext (bar-line::bar-y-extent bar refp))
+                            (staff-symbol (ly:grob-object bar 'staff-symbol)))
+
+                        (if (ly:grob? staff-symbol)
+                            (let ((refp-extent (ly:grob-extent staff-symbol refp Y)))
+
+                              (set! ext (interval-union ext refp-extent))
+
+                              (if (> (interval-length ext) 0)
+                                  (begin
+                                    (set! extents (append extents (list ext)))
+                                    (set! model-bar bar)
+                                    (set! make-span-bars
+                                          (append make-span-bars
+                                                  (list (ly:grob-property
+                                                         bar
+                                                         'allow-span-bar
+                                                         #t))))))))))
+                    elts)
           ;; if there is no bar grob, we use the callback argument
           (if (not model-bar)
               (set! model-bar grob))
index c366a70b544925abd1543ae43e763383f942822f..f7ba6b4edf220fb931428d0c967a7493ffd3c178 100644 (file)
@@ -226,15 +226,15 @@ See @file{double-plus-new-chord-name.scm} for the signature of @var{style}.
             partial-markup-prefix
             (make-normal-size-super-markup
              (markup-join
-              (apply append
-                     (map step->markup
-                          (append altered
-                                  (if (and (> (step-nr highest) 5)
-                                           (not
-                                            (step-even-or-altered? highest)))
-                                      (list highest) '())))
-                     (list partial-markup-suffix)
-                     (list (map sub->markup missing)))
+              (append
+               (map step->markup
+                    (append altered
+                            (if (and (> (step-nr highest) 5)
+                                     (not
+                                      (step-even-or-altered? highest)))
+                                (list highest) '())))
+               (list partial-markup-suffix)
+               (map sub->markup missing))
               sep)))))))
 
 
index b90d7c4ed5a95da6091ea81b551a2e8c0779043e..fc32e6ba759dce9d447b3193a2121b06fc64dad1 100644 (file)
@@ -242,7 +242,7 @@ work than classifying the pitches."
           ;; no exception.
           ;; handle sus4 and sus2 suffix: if there is a 3 together with
           ;; sus2 or sus4, then we explicitly say add3.
-          (map
+          (for-each
            (lambda (j)
              (if (get-step j pitches)
                  (begin
index 097ffdc370f25c92894f330d80aa1aef15d5b923..9b1b4e71cac46f1325092a7c3837800e97a7fb44 100644 (file)
 
 ;; make sure that \property Foo.Bar =\turnOff doesn't complain
 
-(map (lambda (x)
-       ;; (display (car x)) (newline)
+(for-each (lambda (x)
+            ;; (display (car x)) (newline)
 
-       (set-object-property! (car x) 'translation-type? list?)
-       (set-object-property! (car x) 'is-grob? #t))
-     all-grob-descriptions)
+            (set-object-property! (car x) 'translation-type? list?)
+            (set-object-property! (car x) 'is-grob? #t))
+          all-grob-descriptions)
 
 (set! all-grob-descriptions (sort all-grob-descriptions alist<?))
index be87af5191aeb0be36b9191a8d91abe8657eaf00..ca4fac36a9628d518d6fbea36106f7722ebdf6b2 100644 (file)
@@ -1516,7 +1516,7 @@ the line width, where @var{X} is the number of staff spaces.
                                                  justify word-space
                                                  line-width text-direction)))
                           list-para-words)))
-    (apply append para-lines)))
+    (concatenate para-lines)))
 
 (define-markup-command (wordwrap-string layout props arg)
   (string?)
index 6136af0c511605d48bc928b9c81dbc84414f85ea..62ef21a72c2b4b9e183bdb6ac67214acae3dd138 100644 (file)
     ))
 
 ;; add two native utf-8 aliases. Pairs obey cp-like order: '(old new)
-(map (lambda (pair)
-       (set! language-pitch-names
-             (append language-pitch-names
-                     (list (cons (cadr pair)
-                                 (cdr (assoc (car pair) language-pitch-names)))))))
-     '((espanol español)
-       (italiano français)))
+(for-each
+ (lambda (pair)
+   (set! language-pitch-names
+         (append language-pitch-names
+                 (list (cons (cadr pair)
+                             (cdr (assoc (car pair) language-pitch-names)))))))
+ '((espanol español)
+   (italiano français)))
 
 (define-public (note-names-language parser str)
   (_ "Select note names language.")
index a0a18603c2d3244356aec8b0464bd797180c7742..4c834591a392bc90d2b7fdaa49515b7518c677a0 100644 (file)
@@ -70,6 +70,6 @@ are used internally in @file{lily/@/stencil-interpret.cc}."
     transparent-stencil
     ))
 
-(map ly:register-stencil-expression
-     (append (ly:all-stencil-commands)
-             (ly:all-output-backend-commands)))
+(for-each ly:register-stencil-expression
+          (append (ly:all-stencil-commands)
+                  (ly:all-output-backend-commands)))
index 16a4474b7e966d8736a8790af1b4f0def4e30e00..0847d4c93f84ac32eea90f067c63f55a1660169d 100644 (file)
@@ -1021,7 +1021,7 @@ returns @samp{1/3}."
         (*
          (car slope-offset1)
          (+ keylen (list-ref first-bezier 6))) (cdr slope-offset1))))
-   ((if bezier? (lambda (x) `(,(apply append x))) identity)
+   ((if bezier? (lambda (x) `(,(concatenate x))) identity)
     `((,(+ (+ keylen 1.75) (list-ref first-bezier 6))
        ,(+
          (*
index f1190f13c69fe34fd72cc7f47849821392380f0d..5b34ac94fcda7212551236f542c52d85996f74e6 100644 (file)
         possibility-list))))
 
 (define (translate-draw-instructions input-alist key-name-alist)
-  (apply append
-         (map (lambda (short long)
+  (append-map (lambda (short long)
                 (let*
                     ((key-instructions
                       (map (lambda (instr)
                            (assoc-get long key-name-alist))))
                   (key-crawler (assoc-get short input-alist) key-instructions)))
               '(hd cc lh rh)
-              '(hidden central-column left-hand right-hand))))
+              '(hidden central-column left-hand right-hand)))
 
 (define (uniform-draw-instructions key-name-alist)
-  (apply append
-         (map (lambda (long)
+  (append-map (lambda (long)
                 (map (lambda (key-instructions)
                        `((,long . ,(car key-instructions)) . 1))
                      (assoc-get long key-name-alist)))
-              '(hidden central-column left-hand right-hand))))
+              '(hidden central-column left-hand right-hand)))
 
 (define (list-all-possible-keys key-name-alist)
   (map (lambda (short long)
index a4c25cfe3cbcda60717f0c4fa1e311f89f8d9d9f..c1288deff52bc03e8bfad40e62de628bdd8d23c1 100644 (file)
@@ -24,7 +24,7 @@
 
 ;; properly sort all grobs, properties, and interfaces
 ;; within the all-grob-descriptions alist
-(map
+(for-each
  (lambda (x)
    (let* ((props      (assoc-ref all-grob-descriptions (car x)))
           (meta       (assoc-ref props 'meta))
 
 (define iface->grob-table (make-hash-table 61))
 ;; extract ifaces, and put grob into the hash table.
-(map
+(for-each
  (lambda (x)
    (let* ((meta (assoc-get 'meta (cdr x)))
           (ifaces (assoc-get 'interfaces meta)))
 
-     (map (lambda (iface)
-            (hashq-set!
-             iface->grob-table iface
-             (cons (car x)
-                   (hashq-ref iface->grob-table iface '()))))
-          ifaces)))
+     (for-each (lambda (iface)
+                 (hashq-set!
+                  iface->grob-table iface
+                  (cons (car x)
+                        (hashq-ref iface->grob-table iface '()))))
+               ifaces)))
  all-grob-descriptions)
 
 ;; First level Interface description
@@ -178,17 +178,17 @@ node."
 
 ;;;;;;;;;; check for dangling backend properties.
 (define (mark-interface-properties entry)
-  (map (lambda (x) (set-object-property! x 'iface-marked #t))
-       (caddr (cdr entry))))
+  (for-each (lambda (x) (set-object-property! x 'iface-marked #t))
+            (caddr (cdr entry))))
 
-(map mark-interface-properties interface-description-alist)
+(for-each mark-interface-properties interface-description-alist)
 
 (define (check-dangling-properties prop)
   (if (not (object-property prop 'iface-marked))
       (ly:error (string-append "define-grob-properties.scm: "
                                (_ "cannot find interface for property: ~S")) prop)))
 
-(map check-dangling-properties all-backend-properties)
+(for-each check-dangling-properties all-backend-properties)
 
 ;;;;;;;;;;;;;;;;
 
index fc3c4ad28a7101ba4748280a2908d8156943bb09..f5034d2ecc10129e8603ea52eeaf94157234bc41 100644 (file)
      (map document-mod-list mod-list))))
 
 (define (document-mod obj-pair)
-  (cond
-   ((ly:context-mod? (cdr obj-pair))
-    (document-context-mod obj-pair))
-   (else
-    #f)))
+  (and (ly:context-mod? (cdr obj-pair))
+       (document-context-mod obj-pair)))
 
 (define context-mods-doc-string
   (format
 @end table
 "
    (string-join
-    (filter
-     identity
-     (map
-      document-mod
-      (sort
-       (ly:module->alist (current-module))
-       identifier<?)))
-    "")))
+    (filter-map
+     document-mod
+     (sort
+      (ly:module->alist (current-module))
+      identifier<?)))
+   ""))
index 282bf240443c58ebaa6b0ea1ebb1f421466da5c3..2102f640e0f80ad6255be2c5a0e5fffd1c7ada86 100644 (file)
@@ -50,6 +50,6 @@
       #:name "Scheme functions"
       #:desc "Primitive functions exported by LilyPond."
       #:text
-      (apply string-append sfdocs))))
+      (string-concatenate sfdocs))))
 
 ;; (dump-node (all-scheme-functions-doc)  (current-output-port) 0 )
index e17f7d308c086100ecdc2fc7979b6402d6604aa4..22088605d70f7fbaa1df1d9c27ccc4fb21d51b58 100644 (file)
@@ -42,7 +42,7 @@
 ~a
 "
             name-sym (car type-names)
-            (if (equal? "" signature-str) "" " - ") signature-str
+            (if (string-null? signature-str) "" " - ") signature-str
             name-sym
             (if doc
                 doc
 
 
 (define (document-object obj-pair)
-  (cond
-   ((ly:music-function? (cdr obj-pair))
-    (document-music-function obj-pair))
-   (else
-    #f)))
+  (and (ly:music-function? (cdr obj-pair))
+       (document-music-function obj-pair)))
 
 (define-public (identifiers-doc-string)
   (format #f
 @end table
 "
           (string-join
-           (filter
-            identity
-            (map
-             document-object
-             (sort
-              (ly:module->alist (current-module))
-              identifier<?)))
-           "")))
+           (filter-map
+            document-object
+            (sort
+             (ly:module->alist (current-module))
+             identifier<?)))
+          ""))
index 7096a09ec52c4993b6a181b70072740c3f867682..54c987b9bbdb6aa0c8b4fc89890c24647468c591 100644 (file)
@@ -69,7 +69,7 @@
        (if (null? prop-strings)
            "\n"
            (string-append "\n\n\nUsed properties:\n@itemize\n"
-                          (apply string-append prop-strings)
+                          (string-concatenate prop-strings)
                           "@end itemize\n"))))))
 
 (define (markup-function<? a b)
@@ -91,9 +91,9 @@
       #:desc ""
       #:text (string-append
               "@table @asis"
-              (apply string-append
-                     (map doc-markup-function
-                          (sort markup-functions markup-function<?)))
+              (string-concatenate
+               (map doc-markup-function
+                    (sort markup-functions markup-function<?)))
               "\n@end table"))))
 
 (define (markup-doc-node)
 (define (markup-list-doc-string)
   (string-append
    "@table @asis"
-   (apply string-append
-          (map doc-markup-function
-               (sort (hash-fold (lambda (markup-list-function dummy functions)
-                                  (cons markup-list-function functions))
-                                '()
-                                markup-list-functions)
-                     markup-function<?)))
+   (string-concatenate
+    (map doc-markup-function
+         (sort (hash-fold (lambda (markup-list-function dummy functions)
+                            (cons markup-list-function functions))
+                          '()
+                          markup-list-functions)
+               markup-function<?)))
    "\n@end table"))
index ef31ec1f6aa3c809deaf8515dbf0271b7b30966c..0badbf899e14880b59b93ae85be57dc1ea6b060a 100644 (file)
       texi)))
 
 (define music-types->names (make-hash-table 61))
-(filter-map (lambda (entry)
-              (let* ((class (ly:camel-case->lisp-identifier (car entry)))
-                     (classes (ly:make-event-class class)))
-                (if classes
-                    (map
-                     (lambda (cl)
-                       (hashq-set! music-types->names cl
-                                   (cons (car entry)
-                                         (hashq-ref music-types->names cl '()))))
-                     classes)
-                    #f)))
 
-            music-descriptions)
+(for-each (lambda (entry)
+            (let* ((class (ly:camel-case->lisp-identifier (car entry)))
+                   (classes (ly:make-event-class class)))
+              (if classes
+                  (for-each
+                   (lambda (cl)
+                     (hashq-set! music-types->names cl
+                                 (cons (car entry)
+                                       (hashq-ref music-types->names cl '()))))
+                   classes))))
+          music-descriptions)
 
 (define (strip-description x)
   (cons (symbol->string (car x))
index 8237260c4555b3897712b25f561d92ca7ecde9ff..5e867bb4c24bfc84193a90a41ca300522043d689 100644 (file)
          (let* ((layout-alist (ly:output-description $defaultlayout))
                 (context-description-alist (map cdr layout-alist))
                 (contexts
-                 (apply append
-                        (map
-                         (lambda (x)
-                           (let* ((context (assoc-get 'context-name x))
-                                  (group (assq-ref x 'group-type))
-                                  (consists (append
-                                             (if group
-                                                 (list group)
-                                                 '())
-                                             (assoc-get 'consists x))))
-                             (if (member name-sym consists)
-                                 (list context)
-                                 '())))
-                         context-description-alist)))
+                 (append-map
+                  (lambda (x)
+                    (let* ((context (assoc-get 'context-name x))
+                           (group (assq-ref x 'group-type))
+                           (consists (append
+                                      (if group
+                                          (list group)
+                                          '())
+                                      (assoc-get 'consists x))))
+                      (if (member name-sym consists)
+                          (list context)
+                          '())))
+                  context-description-alist))
                 (context-list (human-listify (map ref-ify
                                                   (sort
                                                    (map symbol->string contexts)
 
 ;; Second level, part of Context description
 (define name->engraver-table (make-hash-table 61))
-(map
+(for-each
  (lambda (x)
    (hash-set! name->engraver-table (ly:translator-name x) x))
  (ly:get-all-translators))
        "."
 
        (if (and (pair? props) (not (null? props)))
-           (let ((str (apply string-append
-                             (sort (map document-property-operation props)
-                                   ly:string-ci<?))))
+           (let ((str (string-concatenate
+                       (sort (map document-property-operation props)
+                             ly:string-ci<?))))
              (if (string-null? str)
                  ""
                  (string-append
                         (list group)
                         '())
                     (assoc-get 'consists context-desc)))
-         (grobs  (apply append
-                        (map engraver-grobs consists))))
+         (grobs (append-map engraver-grobs consists)))
     grobs))
 
 (define (all-contexts-doc)
index e6cff904c3ab95890ff54010d4acbddc369227c4..2e94f2c3f869ed35f13bc53ea102306999fcf6e5 100644 (file)
@@ -40,9 +40,9 @@
    "\n"
    "@multitable @columnfractions .33 .66\n"
    "@headitem Type predicate @tab Description\n"
-   (apply string-append
-          (sort (map document-type-predicate alist)
-                ly:string-ci<?))
+   (string-concatenate
+    (sort (map document-type-predicate alist)
+          ly:string-ci<?))
    "@end multitable\n"
    "\n"))
 
@@ -56,8 +56,7 @@
    "* LilyPond exported predicates::\n"
    "@end menu\n"
    "\n"
-   (apply
-    string-append
+   (string-concatenate
     (map
      (lambda (alist-nodename-list)
        (apply document-type-predicate-category
index cc4db2fb2d2ccf30c4739ea92225ef4d0308db14..d65d0edab7ad7fc969aa99b477c1a0dd9427c763 100644 (file)
 
 (use-modules (scm accreg))
 
-(map ly:load '("documentation-lib.scm"
-               "lily-sort.scm"
-               "document-functions.scm"
-               "document-translation.scm"
-               "document-music.scm"
-               "document-type-predicates.scm"
-               "document-identifiers.scm"
-               "document-context-mods.scm"
-               "document-backend.scm"
-               "document-markup.scm"))
+(for-each ly:load '("documentation-lib.scm"
+                    "lily-sort.scm"
+                    "document-functions.scm"
+                    "document-translation.scm"
+                    "document-music.scm"
+                    "document-type-predicates.scm"
+                    "document-identifiers.scm"
+                    "document-context-mods.scm"
+                    "document-backend.scm"
+                    "document-markup.scm"))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
index 49a251720d4f78c7df5cb6125372e930110871ed..a0981945869823034d5c09434231923cde62d3db 100644 (file)
@@ -52,8 +52,8 @@
               (node-children node)))
         ""))
    port)
-  (map (lambda (x) (dump-node x port (+ 1 level)))
-       (node-children node)))
+  (for-each (lambda (x) (dump-node x port (+ 1 level)))
+            (node-children node)))
 
 (define (processing name)
   (ly:basic-progress (_ "Processing ~S...") name))
@@ -101,7 +101,7 @@ string-to-use).  If QUOTE? is #t, embed table in a @quotation environment."
    "\n"
    (if quote? "@quotation\n" "")
    "@table @asis\n"
-   (apply string-append (map one-item->texi items-alist))
+   (string-concatenate (map one-item->texi items-alist))
    "\n"
    "@end table\n"
    (if quote? "@end quotation\n" "")))
@@ -113,14 +113,14 @@ string-to-use).  If QUOTE? is #t, embed table in a @quotation environment."
 
     (string-append
      "\n@menu"
-     (apply string-append
-            (map (lambda (x)
-                   (string-append
-                    (string-pad-right
-                     (string-append "\n* " (car x) ":: ")
-                     (+ maxwid 8))
-                    (cdr x)))
-                 items-alist))
+     (string-concatenate
+      (map (lambda (x)
+             (string-append
+              (string-pad-right
+               (string-append "\n* " (car x) ":: ")
+               (+ maxwid 8))
+              (cdr x)))
+           items-alist))
      "\n@end menu\n"
      ;; Menus don't appear in html, so we make a list ourselves
      "\n@ignore\n"
index 8753019fa79d0d3bb452125bae4efa222c3dc216..45a54b5f8d6ec9a5e202c23381d76ca9697eee6a 100644 (file)
     #:children (make-hash-table 11)))
 
 (define-method (display (leaf <Font-tree-leaf>) port)
-  (map (lambda (x) (display x port))
-       (list
-        "#<Font-size-family:\n"
-        (slot-ref leaf 'default-size)
-        (slot-ref leaf 'size-vector)
-        "#>"
-        )))
+  (for-each (lambda (x) (display x port))
+            (list
+             "#<Font-size-family:\n"
+             (slot-ref leaf 'default-size)
+             (slot-ref leaf 'size-vector)
+             "#>"
+             )))
 
 (define-method (display (node <Font-tree-node>) port)
-  (map
+  (for-each
    (lambda (x)
      (display x port))
    (list
index 3517f90ebbf01ce2dbc93c260d3cd528efac2030..d92affb11ccad4c45953c36a81ab8128af576335 100644 (file)
         (list (ly:font-name font))))
 
   (let* ((fonts (ly:paper-fonts paper))
-         (names (apply append (map extract-names fonts))))
-    (apply string-append
-           (map (lambda (f)
-                  (format #f
-                          (if load-fonts?
-                              "%%DocumentSuppliedResources: font ~a\n"
-                              "%%DocumentNeededResources: font ~a\n")
-                          f))
-                (uniq-list (sort names string<?))))))
+         (names (append-map extract-names fonts)))
+    (string-concatenate
+     (map (lambda (f)
+            (format #f
+                    (if load-fonts?
+                        "%%DocumentSuppliedResources: font ~a\n"
+                        "%%DocumentNeededResources: font ~a\n")
+                    f))
+          (uniq-list (sort names string<?))))))
 
 (define (eps-header paper bbox load-fonts?)
   (string-append "%!PS-Adobe-2.0 EPSF-2.0\n"
                       (ly:font-sub-fonts font))))
              fonts))
            (font-names (uniq-list
-                        (sort (apply append all-font-names)
+                        (sort (concatenate all-font-names)
                               (lambda (x y) (string<? (cadr x) (cadr y))))))
 
            ;; slightly spaghetti-ish: deciding what to load where
index 22e5b6730210663a3ee59a6f3e7ba8b2ef807456..43b05e57c20d8fa6b5b9e784d434cb5c564d1c58 100644 (file)
@@ -535,10 +535,7 @@ For example:
          (list elem)))
    '() lst))
 
-(define-public (filtered-map proc lst)
-  (filter
-   (lambda (x) x)
-   (map proc lst)))
+(define-public filtered-map filter-map)
 
 (define-public (flatten-list x)
   "Unnest list."
index 0f711ed19331df8fdc185e87d4bf1f605199c570..4a63be9908d92cd791746f7435e4030bee19fb45 100644 (file)
@@ -841,11 +841,10 @@ messages into errors.")
 
   (let* ((stat (gulp-file "/proc/self/status"))
          (lines (string-split stat #\newline))
-         (interesting (filter identity
-                              (map
-                               (lambda (l)
-                                 (string-match "^VmData:[ \t]*([0-9]*) kB" l))
-                               lines)))
+         (interesting (filter-map
+                       (lambda (l)
+                         (string-match "^VmData:[ \t]*([0-9]*) kB" l))
+                       lines))
          (mem (string->number (match:substring (car interesting) 1))))
     (format #t "VMDATA: ~a\n" mem)
     (display (gc-stats))
@@ -898,12 +897,11 @@ PIDs or the number of the process."
              (ly:exit 2 #t)))
   (if (ly:get-option 'read-file-list)
       (set! files
-            (filter (lambda (s)
-                      (> (string-length s) 0))
-                    (apply append
-                           (map (lambda (f)
-                                  (string-split (string-delete (ly:gulp-file f) #\cr) #\nl))
-                                files)))))
+            (remove string-null?
+                    (append-map
+                     (lambda (f)
+                       (string-split (string-delete (ly:gulp-file f) #\cr) #\nl))
+                     files))))
   (if (and (number? (ly:get-option 'job-count))
            (>= (length files) (ly:get-option 'job-count)))
       (let* ((count (ly:get-option 'job-count))
index 3db3904726437ec0f1e218d7b5ffc7e86b74e412..71892bde65e5d1a0eab09f7f1db2d3813d2e3e59 100644 (file)
@@ -120,7 +120,7 @@ LilyPond scheme pitches, e.g. @code{(ly:make-pitch 0 2 0)}
       (ly:music-set-property! music 'pitch (converter pitch)))
 
      ((pair? elements)
-      (map (lambda (x) (change-pitches x converter)) elements))
+      (for-each (lambda (x) (change-pitches x converter)) elements))
 
      ((ly:music? element)
       (change-pitches element converter)))))
@@ -206,7 +206,7 @@ Typically used to construct a scale for input to transposer-factory
     (if (ly:dir? span-dir)
         (ly:music-set-property! music 'span-direction (- span-dir)))
 
-    (map retrograde-music reversed)
+    (for-each retrograde-music reversed)
 
     music))
 
index fb29e73cd2d4cc79d752c1606e77654fce4584d3..afcdb843e72545e3f20a1922a737a58a08044577 100644 (file)
@@ -137,7 +137,7 @@ For instance,
                                                                   (string-length "-markup")))))))
   (define (transform-arg arg)
     (cond ((and (pair? arg) (markup? (car arg))) ;; a markup list
-           (apply append (map inner-markup->make-markup arg)))
+           (append-map inner-markup->make-markup arg))
           ((and (not (string? arg)) (markup? arg)) ;; a markup
            (inner-markup->make-markup arg))
           (else                                  ;; scheme arg
@@ -164,12 +164,12 @@ equivalent to @var{obj}, that is, for a music expression, a
          (ly:music? obj)
          `(make-music
            ',(ly:music-property obj 'name)
-           ,@(apply append (map (lambda (prop)
-                                  `(',(car prop)
-                                    ,(music->make-music (cdr prop))))
-                                (remove (lambda (prop)
-                                          (eqv? (car prop) 'origin))
-                                        (ly:music-mutable-properties obj))))))
+           ,@(append-map (lambda (prop)
+                           `(',(car prop)
+                             ,(music->make-music (cdr prop))))
+                         (remove (lambda (prop)
+                                   (eqv? (car prop) 'origin))
+                                 (ly:music-mutable-properties obj)))))
         (;; moment
          (ly:moment? obj)
          `(ly:make-moment ,(ly:moment-main-numerator obj)
@@ -1953,9 +1953,9 @@ base onto the following musical context."
                (layout (ly:grob-layout root))
                (blot (ly:output-def-lookup layout 'blot-diameter)))
           ;; Hide spanned stems
-          (map (lambda (st)
-                 (set! (ly:grob-property st 'stencil) #f))
-               stems)
+          (for-each (lambda (st)
+                      (set! (ly:grob-property st 'stencil) #f))
+                    stems)
           ;; Draw a nice looking stem with rounded corners
           (ly:round-filled-box (ly:grob-extent root root X) yextent blot))
         ;; Nothing to connect, don't draw the span
@@ -1987,7 +1987,7 @@ other stems just because of that."
   ;; two stems at this musical moment
   (if (<= 2 (length stems))
       (let ((roots (filter stem-is-root? stems)))
-        (map (make-stem-span! stems trans) roots))))
+        (for-each (make-stem-span! stems trans) roots))))
 
 (define-public (Span_stem_engraver ctx)
   "Connect cross-staff stems to the stems above in the system"
index 33a03139dead37a6f1e6a09d3cf57259ef466e6e..dc88b4387a8f00e87031a233c656642b3b533736 100644 (file)
@@ -620,8 +620,8 @@ and duration-log @var{log}."
 (define-public (color? x)
   (and (list? x)
        (= 3 (length x))
-       (apply eq? #t (map number? x))
-       (apply eq? #t (map (lambda (y) (<= 0 y 1)) x))))
+       (every number? x)
+       (every (lambda (y) (<= 0 y 1)) x)))
 
 (define-public (rgb-color r g b) (list r g b))
 
index 1df5a53d703bec054ba29eb566de86ab4c6b2511..cb9f598d3f0b71cc7ca261a77f17abd2c63df87e 100644 (file)
 
 ;; Helper functions
 (define-public (attributes attributes-alist)
-  (apply string-append
-         (map (lambda (x)
-                (let ((attr (car x))
-                      (value (cdr x)))
-                  (if (number? value)
-                      (set! value (ly:format "~4f" value)))
-                  (format #f " ~s=\"~a\"" attr value)))
-              attributes-alist)))
+  (string-concatenate
+   (map (lambda (x)
+          (let ((attr (car x))
+                (value (cdr x)))
+            (if (number? value)
+                (set! value (ly:format "~4f" value)))
+            (format #f " ~s=\"~a\"" attr value)))
+        attributes-alist)))
 
 (define-public (eo entity . attributes-alist)
   "o = open"
   (integer->entity (char->integer char)))
 
 (define (string->entities string)
-  (apply string-append
-         (map (lambda (x) (char->entity x)) (string->list string))))
+  (string-concatenate
+   (map char->entity (string->list string))))
 
 (define svg-element-regexp
   (make-regexp "^(<[a-z]+) ?(.*>)"))
             `(stroke-linecap . ,(symbol->string cap-style))
             '(stroke . "currentColor")
             `(fill . ,(if fill? "currentColor" "none"))
-            `(d . ,(apply string-append (convert-path-exps commands))))))
+            `(d . ,(string-concatenate (convert-path-exps commands))))))
 
 (define (placebox x y expr)
   (if (string-null? expr)
index 428b95c87b5da8a022412f5f5ccc4e9847658ea7..f6bb29d701be0c331fadf51fe6b4410a570de06d 100644 (file)
                     (append (cdr lines) (list #f)))
           (paper-system-annotate-last (car (last-pair lines)) layout)))
 
-    (map add-system lines)
+    (for-each add-system lines)
 
 
     (ly:prob-set-property! page 'bottom-system-edge
index 719cc4ce503c48af362e276883ac623d2b572711..6ba1261ca726846bf4093a9f11fc748d21e66766 100644 (file)
   "Generate the clef setting commands for a clef with name @var{clef-name}."
   (define (make-prop-set props)
     (let ((m (make-music 'PropertySet)))
-      (map (lambda (x) (set! (ly:music-property m (car x)) (cdr x))) props)
+      (for-each (lambda (x) (set! (ly:music-property m (car x)) (cdr x))) props)
       m))
   (let ((e '())
         (c0 0)
index dadce948634ccae8db3a4eef0d17e4fd7828bbf3..4e3e4b66031c178316ecb7a340fe0f32600842b6 100644 (file)
@@ -275,9 +275,9 @@ LilyPond version 2.8 and earlier."
     (define (analyse-forced-combine result-idx prev-res)
 
       (define (get-forced-event x)
-        (if (ly:in-event-class? x 'part-combine-force-event)
-            (cons (ly:event-property x 'forced-type) (ly:event-property x 'once))
-            #f))
+        (and (ly:in-event-class? x 'part-combine-force-event)
+             (cons (ly:event-property x 'forced-type)
+                   (ly:event-property x 'once))))
       (define (part-combine-events vs)
         (if (not vs)
             '()
@@ -338,7 +338,7 @@ Only set if not set previously.
                  (prev (configuration prev-ss)))
             (if (symbol? prev)
                 (put prev))))
-        (map copy-one-state (span-state vs)))
+        (for-each copy-one-state (span-state vs)))
 
       (define (analyse-notes now-state)
         (let* ((vs1 (car (voice-states now-state)))
index 34887b0aec0bb1755223ad2838a823d44c604d88..948e56e145a5a4ea7a12f5e988c49cc2ef848afd 100644 (file)
 
      (if (not (= 0 status))
          (begin
-           (map delete-file files)
+           (for-each delete-file files)
            (exit 1)))
 
      (if (and rename-page-1 multi-page?)
index cfc088c8b37dd6cd9d069452d66745e9c066094c..25209e5a0b698e412ac53220851b0f12d7a6adb0 100644 (file)
@@ -15,7 +15,7 @@
 ;;;; You should have received a copy of the GNU General Public License
 ;;;; along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
 
-(map
+(for-each
  (lambda (sym)
    (set! safe-objects (cons (cons sym (primitive-eval sym))
                             safe-objects)))
index c0c226d7c2268cdc907e523aa0b212accb537a06..31cb1e8d48c2d35565127a0117d9d77e4ae0f0d7 100644 (file)
                         ((record-constructor ,record) ,@(map car slots*))))
          (set! ,$copy-record
                (lambda (record)
-                 (,$make-record ,@(apply
-                                   append
-                                   (map (lambda (slot)
-                                          (list (symbol->keyword slot)
-                                                (list (make-symbol reader-format slot) 'record)))
-                                        (map car slots*))))))
+                 (,$make-record ,@(append-map
+                                   (lambda (slot)
+                                     (list (symbol->keyword slot)
+                                           (list (make-symbol reader-format slot) 'record)))
+                                   (map car slots*)))))
          ,@(map (lambda (s)
                   `(set! ,(make-symbol reader-format (car s))
                          (record-accessor ,record (quote ,(car s)))))
index 65852fc305a0ba9469784a69372886d6e0a14251..0833382b6132c9a675572e4c0c8179a6829e4061 100644 (file)
@@ -246,16 +246,16 @@ the partial ellipse until 7*PI/2.  For example, in pseudo-code:
 \n((0.0 . 2) (PI/2 . 3) (PI . -2) (3*PI/2 . -3)\
 \n(2*PI . 2) (5*PI/2 . 3) (3*PI . -2) (7*PI/2 . -3))
 "
-    (apply append
-           (map (lambda (adder)
-                  (map (lambda (quadrant)
-                         (cons (+ adder (car quadrant))
-                               (cdr quadrant)))
-                       `((0.0 . (,x-radius . 0.0))
-                         (,PI-OVER-TWO . (0.0 . ,y-radius))
-                         (,PI . (,(- x-radius) . 0.0))
-                         (,THREE-PI-OVER-TWO . (0.0 . ,(- y-radius))))))
-                `(0.0 ,TWO-PI))))
+    (append-map
+     (lambda (adder)
+       (map (lambda (quadrant)
+              (cons (+ adder (car quadrant))
+                    (cdr quadrant)))
+            `((0.0 . (,x-radius . 0.0))
+              (,PI-OVER-TWO . (0.0 . ,y-radius))
+              (,PI . (,(- x-radius) . 0.0))
+              (,THREE-PI-OVER-TWO . (0.0 . ,(- y-radius))))))
+     `(0.0 ,TWO-PI)))
 
   (define
     (insert-in-ordered-list ordering-function value inlist cutl? cutr?)
@@ -304,7 +304,7 @@ then reduce using @var{min-max}:
 "
     (reduce min-max
             (if (eq? min-max min) 100000 -100000)
-            (map (lambda (x) (side x)) l)))
+            (map side l)))
 
   (let*
       (;; the outside limit of the x-radius
@@ -647,12 +647,12 @@ with optional arrows of @code{max-size} on start and end controlled by
          (null (cons 0 0))
          (arrow-1
           (ly:make-stencil
-           `(polygon (quote ,(concatenate (map complex-to-offset p1s)))
+           `(polygon (quote ,(append-map complex-to-offset p1s))
                      0.0
                      #t) null null))
          (arrow-2
           (ly:make-stencil
-           `(polygon (quote ,(concatenate (map complex-to-offset p2s)))
+           `(polygon (quote ,(append-map complex-to-offset p2s))
                      0.0
                      #t) null null ) )
          (thickness (min (/ distance 12) 0.1))
index d62f0aa0178211e5d4e58b3216aefedc233c6319..e32d712e19ae97986b84422a2e99b2fa8dd5fe22 100644 (file)
         (elt (ly:music-property mus 'element)))
     (cond
      ((pair? elts)
-      (map make-harmonic elts))
+      (for-each make-harmonic elts))
      ((ly:music? elt)
       (make-harmonic elt))
      ((music-is-of-type? mus 'note-event)
index e2102e759ef0705cf26b51ac3e28a91cb188e9fb..82e22fe59197e97ae601849beccbcafa7e495626 100644 (file)
@@ -381,8 +381,8 @@ a fresh copy of the list-head is made."
   ;; Normalize to given beat, extract the beats and join them to one list
   (let* ((beat (calculate-compound-base-beat-full time-sig))
          (normalized (map (lambda (f) (normalize-fraction f beat)) time-sig))
-         (beats (map (lambda (f) (reverse (cdr (reverse f)))) normalized)))
-    (apply append beats)))
+         (beats (map (lambda (f) (drop-right f 1)) normalized)))
+    (concatenate beats)))
 
 (define-public (calculate-compound-beat-grouping time-sig)
   (cond
index 8b33cbaccc26ed5baf9d9c154efaea7f00e03938..2407fe3766239939a0c33d162eae75c7900a472e 100644 (file)
@@ -70,7 +70,7 @@ is then separated.
      (if (equal? (node-value node) "")
          (string-append
           (if xml-name "\n" "")
-          (apply string-append (map musicxml-node->string (node-children node))))
+          (string-concatenate (map musicxml-node->string (node-children node))))
          (node-value node))
      (if xml-name (close-tag xml-name) "")
      (if xml-name "\n" ""))))
@@ -80,8 +80,7 @@ is then separated.
    "\n"
    (open-tag (node-name node) (node-attributes node) '())
    (if (equal? (node-value node) "")
-       (string-append
-        (apply string-append (map xml-node->string (node-children node))))
+       (string-concatenate (map xml-node->string (node-children node)))
        (node-value node))
    "\n"
    (close-tag (node-name node))))
@@ -224,7 +223,7 @@ is then separated.
 
   (string-append
    "<" (symbol->string tag)
-   (apply string-append (map dump-attr (filter candidate? attrs)))
+   (string-concatenate (map dump-attr (filter candidate? attrs)))
    ">"))
 
 (define (close-tag name)
index 823668830a71ba96d520f48f291f29bd525cf4d2..9bc12cc53c170745b4c5011cfb3b72b059a4d6e9 100644 (file)
@@ -321,14 +321,14 @@ along with @var{minimum-fret}, @var{maximum-stretch}, and
 if no fingering is present."
       (let* ((articulations (ly:event-property ev 'articulations))
              (finger-found #f))
-        (map (lambda (art)
-               (let* ((num (ly:event-property art 'digit)))
-
-                 (if (and (ly:in-event-class? art 'fingering-event)
-                          (number? num)
-                          (> num 0))
-                     (set! finger-found num))))
-             articulations)
+        (for-each (lambda (art)
+                    (let* ((num (ly:event-property art 'digit)))
+
+                      (if (and (ly:in-event-class? art 'fingering-event)
+                               (number? num)
+                               (> num 0))
+                          (set! finger-found num))))
+                  articulations)
         finger-found))
 
     (define (delete-free-string string)