]> git.donarmstrong.com Git - lilypond.git/commitdiff
add count-list function
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 10 Nov 2006 14:26:30 +0000 (15:26 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 10 Nov 2006 14:26:30 +0000 (15:26 +0100)
scm/lily-library.scm

index 7bdf96d05d542a73b97e5a2a9d5f5b1d45e83c87..6e30cf6ae541780e331d2e5602c1d01379665dbe 100644 (file)
@@ -231,6 +231,16 @@ 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."