| find(3scm) | Scheme Programmer's Manual | find(3scm) |
NAME
find - search a list for an element satisfying a predicateLIBRARY
(import (rnrs)) ;R6RS (import (rnrs lists)) ;R6RS
SYNOPSIS
(find proc list)
DESCRIPTION
The find procedure applies proc to the elements of list in order. If proc returns a true value for an element, find immediately returns that element. If proc returns #f for all elements of the list, find returns #f.Proc is always called in the same dynamic environment as find itself.
Proc should accept one argument and return a single value. Proc should not mutate list.
IMPLEMENTATION NOTES
The implementation must check that list is a chain of pairs up to the found element, or that it is indeed a list if no element is found. It should not check that it is a chain of pairs beyond the found element. The implementation must check the restrictions on proc to the extent performed by applying it as described. An implementation may check whether proc is an appropriate argument before applying it.RETURN VALUES
Returns a single value which is either one of the elements of list or #f.EXAMPLES
(find even? '(3 1 4 1 5 9)) => 4 (find even? '(3 1 5 1 5 9)) => #f
ERRORS
This procedure can raise exceptions with the following condition types:- &assertion (R6RS)
- The wrong number of arguments was passed or an argument was outside its domain.
SEE ALSO
member(3scm)STANDARDS
R6RS, SRFI-1HISTORY
This procedure is new in R6RS, which got it from SRFI-1.AUTHORS
This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://weinholt.se/scheme/manpages/.| 2022-03-27 |