diff options
author | Arun Isaac | 2024-09-05 18:29:39 +0100 |
---|---|---|
committer | Arun Isaac | 2024-09-05 18:29:39 +0100 |
commit | 0776a3aa4d7b9a65d785ca7c30f423cb23fca330 (patch) | |
tree | 4269ea12f9007d65b1495f632565f48c4b8a7ecf | |
parent | b2c97647a1827b19e02890c31e528a42d6c4b12c (diff) | |
download | ravanan-0776a3aa4d7b9a65d785ca7c30f423cb23fca330.tar.gz ravanan-0776a3aa4d7b9a65d785ca7c30f423cb23fca330.tar.lz ravanan-0776a3aa4d7b9a65d785ca7c30f423cb23fca330.zip |
vectors: Add vector-filter-map->list.
* ravanan/vectors.scm: Import (srfi srfi-1).
(vector-filter-map->list): New public function.
-rw-r--r-- | ravanan/vectors.scm | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/ravanan/vectors.scm b/ravanan/vectors.scm index bd4f776..b1ea247 100644 --- a/ravanan/vectors.scm +++ b/ravanan/vectors.scm @@ -18,6 +18,7 @@ (define-module (ravanan vectors) #:use-module ((rnrs base) #:select (vector-for-each vector-map)) + #:use-module (srfi srfi-1) #:use-module ((srfi srfi-43) #:select (vector-append (vector-map . vector-map-indexed) vector-any @@ -26,6 +27,7 @@ vector-append-map->list map->vector vector-filter + vector-filter-map->list vector-remove vector-find) #:re-export (vector-append @@ -64,6 +66,11 @@ together." "Return a vector with elements from @var{vec} that pass @var{pred}." (list->vector (filter pred (vector->list vec)))) +(define (vector-filter-map->list proc vec) + "Map @var{proc} over @var{vec} and return a list of the results that are not +@code{#f}." + (filter-map proc (vector->list vec))) + (define (vector-remove proc vec) "Return a vector with elements from @var{vec} that fail @var{pred}." (vector-filter (negate proc) vec)) |