aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-04-05 17:41:37 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2019-04-05 17:41:37 +0200
commitef8dcc12f2b097d46764c8603f4de43ebe7eb827 (patch)
treeca3adffdb6173eae7d7fc6aab5c0748b84f0719a
parentWhitespace fix. (diff)
downloadcalp-ef8dcc12f2b097d46764c8603f4de43ebe7eb827.tar.gz
calp-ef8dcc12f2b097d46764c8603f4de43ebe7eb827.tar.xz
Add enumerate and map-each.
-rw-r--r--module/util.scm11
1 files changed, 11 insertions, 0 deletions
diff --git a/module/util.scm b/module/util.scm
index 0e8ee7ee..bf7d746d 100644
--- a/module/util.scm
+++ b/module/util.scm
@@ -190,3 +190,14 @@
(define-public (as-symb s)
(if (string? s) (string->symbol s) s))
+
+(define-public (enumerate lst)
+ (zip (iota (length lst))
+ lst))
+
+;; Map with index
+(define-syntax-rule (map-each proc lst)
+ (map (lambda (x i) (proc x i))
+ lst (iota (length lst))))
+
+(export map-each)