]> 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 492e38d5ecfc0cf99e56897f95965aca95e6c4f4..6e30cf6ae541780e331d2e5602c1d01379665dbe 100644 (file)
@@ -228,7 +228,34 @@ found."
     m))
 
 ;;;;;;;;;;;;;;;;
-; list
+;; 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)
+   (map proc lst)))
+
 
 (define (flatten-list lst)
   "Unnest LST" 
@@ -483,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)))