From 0776a3aa4d7b9a65d785ca7c30f423cb23fca330 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Thu, 5 Sep 2024 18:29:39 +0100 Subject: vectors: Add vector-filter-map->list. * ravanan/vectors.scm: Import (srfi srfi-1). (vector-filter-map->list): New public function. --- ravanan/vectors.scm | 7 +++++++ 1 file changed, 7 insertions(+) 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)) -- cgit v1.2.3