]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/lily-library.scm
Merge ssh+git://hanwen@repo.or.cz/srv/git/lilypond into master-hanwen
[lilypond.git] / scm / lily-library.scm
index 1e6f407b0963f3e33b668f2847f5c67b592c3081..6e30cf6ae541780e331d2e5602c1d01379665dbe 100644 (file)
@@ -231,6 +231,26 @@ found."
 ;; list
 
 
+(define-public (count-list lst)
+  "Given lst (E1 E2 .. ) return ((E1 . 1) (E2 . 2) ... )  "
+  (define (helper l acc count)
+    (if (pair? l)
+       (helper (cdr l) (cons (cons (car l) count) acc) (1+ count))
+       acc))
+
+
+  (reverse (helper lst '() 1)))
+  
+(define-public (list-join lst intermediate)
+  "put INTERMEDIATE  between all elts of LST."
+
+  (fold-right
+   (lambda (elem prev)
+           (if (pair? prev)
+               (cons  elem (cons intermediate prev))
+               (list elem)))
+         '() lst))
+
 (define-public (filtered-map proc lst)
   (filter
    (lambda (x) x)
@@ -490,7 +510,6 @@ possibly turned off."
 
 (define-public (car< a b) (< (car a) (car b)))
 
-
 (define-public (symbol<? lst r)
   (string<? (symbol->string lst) (symbol->string r)))