diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-04-05 17:41:37 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-04-05 17:41:37 +0200 |
commit | ef8dcc12f2b097d46764c8603f4de43ebe7eb827 (patch) | |
tree | ca3adffdb6173eae7d7fc6aab5c0748b84f0719a /module | |
parent | Whitespace fix. (diff) | |
download | calp-ef8dcc12f2b097d46764c8603f4de43ebe7eb827.tar.gz calp-ef8dcc12f2b097d46764c8603f4de43ebe7eb827.tar.xz |
Add enumerate and map-each.
Diffstat (limited to '')
-rw-r--r-- | module/util.scm | 11 |
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) |