From 6f9f21b9d439f52b28019dba527b288b89a8a7ee Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Fri, 10 Nov 2006 15:26:30 +0100 Subject: [PATCH] add count-list function --- scm/lily-library.scm | 10 ++++++++++ 1 file changed, 10 insertions(+) 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." -- 2.39.5