1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-19 18:20:22 +02:00

srfi-1: Rewrite 'find' in Scheme.

This halves the wall-clock time of:

  guile -c '(use-modules (srfi srfi-1)) (define lst (make-list 100000000 1)) (find zero? lst)'

and yields an 18% speedup on:

  guile -c '(use-modules (srfi srfi-1)) (define lst (make-list 100000000 1)) (find (lambda (x) (= 2 x)) lst)'

* libguile/srfi-1.c (scm_srfi1_find): Remove.
* libguile/srfi-1.h (scm_srfi1_find): Likewise.
* module/srfi/srfi-1.scm (find): New procedure.
* doc/ref/srfi-modules.texi (SRFI-1 Searching): Adjust docstring.
This commit is contained in:
Ludovic Courtès 2020-06-17 16:59:50 +02:00
parent 2e2e13c40a
commit 0360843ace
4 changed files with 16 additions and 29 deletions

View file

@ -1,6 +1,6 @@
@c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual.
@c Copyright (C) 1996, 1997, 2000-2004, 2006, 2007-2014, 2017, 2018, 2019
@c Copyright (C) 1996, 1997, 2000-2004, 2006, 2007-2014, 2017, 2018, 2019, 2020
@c Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions.
@ -824,7 +824,7 @@ predicate or a comparison object for determining which elements are to
be searched.
@deffn {Scheme Procedure} find pred lst
Return the first element of @var{lst} which satisfies the predicate
Return the first element of @var{lst} that satisfies the predicate
@var{pred} and @code{#f} if no such element is found.
@end deffn