mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-19 02:00:26 +02:00
* common-list.scm (count-if): New procedure.
This commit is contained in:
parent
67e8151b65
commit
d69947f744
2 changed files with 12 additions and 0 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2001-03-12 Keisuke Nishida <kxn30@po.cwru.edu>
|
||||||
|
|
||||||
|
* common-list.scm (count-if): New procedure.
|
||||||
|
|
||||||
2001-03-10 Neil Jerram <neil@ossau.uklinux.net>
|
2001-03-10 Neil Jerram <neil@ossau.uklinux.net>
|
||||||
|
|
||||||
* buffered-input.scm (make-buffered-input-port): New, more general
|
* buffered-input.scm (make-buffered-input-port): New, more general
|
||||||
|
|
|
@ -124,6 +124,14 @@ Analogous to some but returns #t as soon as an application of PRED returns #f,
|
||||||
or #f otherwise."
|
or #f otherwise."
|
||||||
(not (apply every pred ls)))
|
(not (apply every pred ls)))
|
||||||
|
|
||||||
|
(define-public (count-if pred l)
|
||||||
|
"Returns the number of elements in L such that (PRED element)
|
||||||
|
returns true."
|
||||||
|
(let loop ((n 0) (l l))
|
||||||
|
(cond ((null? l) n)
|
||||||
|
((pred (car l)) (loop (+ n 1) (cdr l)))
|
||||||
|
(else (loop n (cdr l))))))
|
||||||
|
|
||||||
(define-public (find-if pred l)
|
(define-public (find-if pred l)
|
||||||
"Searches for the first element in L such that (PRED element)
|
"Searches for the first element in L such that (PRED element)
|
||||||
returns true. If it finds any such element in L, element is
|
returns true. If it finds any such element in L, element is
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue