From 912c1375b467b966ed29609e0d6e5c83d04d9ae3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@soeren-tempel.net>
Date: Sat, 17 Aug 2024 15:45:40 +0200
Subject: [PATCH] util: remove for-each-index procedure

Now unused.
---
 lib/util.scm   | 21 ---------------------
 lib/util.sld   |  4 ++--
 tests/util.scm | 33 ---------------------------------
 3 files changed, 2 insertions(+), 56 deletions(-)

diff --git a/lib/util.scm b/lib/util.scm
index 121f02e..a1313b6 100644
--- a/lib/util.scm
+++ b/lib/util.scm
@@ -154,27 +154,6 @@
 (define (ascii-printable? integer)
   (and (>= integer #x20) (<= integer #x7e)))
 
-;;> Call `proc` for each element in `lst` starting at the `start` index.
-;;> For each element, the procedure `proc` is passed both the index as
-;;> well as the element value itself as a procedure parameter.
-
-(define (for-each-index proc cont-proc lst start)
-  (define (%for-each-index vector index rem)
-    (unless (zero? rem)
-      (proc index (vector-ref vector index))
-      (%for-each-index
-        vector
-        (modulo (cont-proc index) (vector-length vector))
-        (dec rem))))
-
-  (unless (null? lst)
-    (let* ((vec (list->vector lst))
-           (len (vector-length vec)))
-      (if (and (>= start 0)
-               (< start len))
-        (%for-each-index vec start len)
-        (error "invalid start index")))))
-
 ;;> Return path to home directory of current user.
 ;;> This procedure emits an error if the environment variable `HOME` is unset.
 
diff --git a/lib/util.sld b/lib/util.sld
index d38770b..418839b 100644
--- a/lib/util.sld
+++ b/lib/util.sld
@@ -12,7 +12,7 @@
           (chicken io))
 
   (export inc dec id alist-values fprintln println empty-string?
-          pad-string string->human-readable for-each-index path-join
-          user-home count-bytes lines->port port->lines)
+          pad-string string->human-readable path-join user-home
+          count-bytes lines->port port->lines)
 
   (include "util.scm"))
diff --git a/tests/util.scm b/tests/util.scm
index dd14cbd..918138c 100644
--- a/tests/util.scm
+++ b/tests/util.scm
@@ -1,38 +1,5 @@
 (import (edward util))
 
-(test-group "for-each-index"
-  (test "increment index from start"
-        '((0 . "foo") (1 . "bar") (2 . "baz"))
-        (let ((ret '()))
-          (for-each-index
-            (lambda (idx elem)
-              (set! ret (append ret (list (cons idx elem)))))
-            inc '("foo" "bar" "baz") 0)
-          ret))
-
-  (test "decrement index from middle"
-        '((1 . "bar") (0 . "foo") (2 . "baz"))
-        (let ((ret '()))
-          (for-each-index
-            (lambda (idx elem)
-              (set! ret (append ret (list (cons idx elem)))))
-            dec '("foo" "bar" "baz") 1)
-          ret))
-
-  (test "zero list"
-        '()
-        (let ((ret '()))
-          (for-each-index
-            (lambda (idx elem)
-              (set! ret idx))
-            inc '() 0)
-          ret))
-
-  (test-error "invalid start index"
-              (for-each-index
-                (lambda (idx elem) elem)
-                inc '(1 2 3) 3)))
-
 (test-group "ports->lines"
   (test "multiple"
         '(("foo" "bar" "baz") . 12)