John, would you please review this patch?

Thanks.

On Fri, Jun 9, 2023 at 4:48 AM Shawn Wagner <[email protected]> wrote:

> The documentation says this function returns two values - a new vector and
> the number of leading elements of it matching the given partition, but the
> reference implementation only returns the vector.
>
> The below patch fixes the function and associated test case to match the
> documentation:
>
> diff --git a/shared-tests.scm b/shared-tests.scm
> index fe609ae..0f08a3a 100644
> --- a/shared-tests.scm
> +++ b/shared-tests.scm
> @@ -142,7 +142,10 @@
>    (test "multi-every-2" 10 (s16vector-every (lambda (x y) (and (exact? x)
> (exact? y) (+ x y)))
>                                      s5 s5))
>    (test-assert "multi-not every" (not (s16vector-every < s5 (s16vector 10
> 10 10 10 0))))
> -  (test-equiv "partition" '(1 3 5 2 4) (s16vector-partition odd? s5))
> +  (test-equiv "partition" '(1 3 5 2 4)
> +              (call-with-values
> +                  (lambda () (s16vector-partition odd? s5))
> +                (lambda (vec cnt) vec)))
>    (test-equiv "filter" '(1 3 5) (s16vector-filter odd? s5))
>    (test-equiv "remove" '(2 4) (s16vector-remove odd? s5))
>  ) ; end s16vector/searching
> diff --git a/srfi/160/at-impl.scm b/srfi/160/at-impl.scm
> index a34560f..f8e4bfb 100644
> --- a/srfi/160/at-impl.scm
> +++ b/srfi/160/at-impl.scm
> @@ -414,7 +414,7 @@
>           (r (make-@vector len)))
>      (let loop ((i 0) (yes 0) (no cnt))
>        (cond
> -        ((= i len) r)
> +        ((= i len) (values r cnt))
>          ((pred (@vector-ref vec i))
>           (@vector-set! r yes (@vector-ref vec i))
>           (loop (+ i 1) (+ yes 1) no))
>
>

Reply via email to