aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2024-09-13 03:01:08 +0100
committerArun Isaac2024-09-13 03:03:01 +0100
commita2143a9868c6371e12f9f185b2e81b3ca36a176b (patch)
tree0e16271fba828a2d13c94920d52fa591227990c4
parentfc1004d6c41c57e5ed9cae5da105e44937722959 (diff)
downloadravanan-a2143a9868c6371e12f9f185b2e81b3ca36a176b.tar.gz
ravanan-a2143a9868c6371e12f9f185b2e81b3ca36a176b.tar.lz
ravanan-a2143a9868c6371e12f9f185b2e81b3ca36a176b.zip
vectors: Add vector-filter-map.
* ravanan/work/vectors.scm (vector-filter-map): New public function.
-rw-r--r--ravanan/work/vectors.scm6
1 files changed, 6 insertions, 0 deletions
diff --git a/ravanan/work/vectors.scm b/ravanan/work/vectors.scm
index 160ff3e..45c87cb 100644
--- a/ravanan/work/vectors.scm
+++ b/ravanan/work/vectors.scm
@@ -29,6 +29,7 @@
vector-append-map->list
map->vector
vector-filter
+ vector-filter-map
vector-filter-map->list
vector-remove
vector-find)
@@ -80,6 +81,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 proc vec)
+ "Map @var{proc} over @var{vec} and return a vector of the results that are not
+@code{#f}."
+ (list->vector (filter-map proc (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}."