From: Han-Wen Nienhuys Date: Fri, 10 Nov 2006 14:26:30 +0000 (+0100) Subject: add count-list function X-Git-Tag: release/2.11.0-1~47 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=6f9f21b9d439f52b28019dba527b288b89a8a7ee;p=lilypond.git add count-list function --- diff --git a/scm/lily-library.scm b/scm/lily-library.scm index 7bdf96d05d..6e30cf6ae5 100644 --- a/scm/lily-library.scm +++ b/scm/lily-library.scm @@ -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."