Improve performance of R6RS records implementation
[bpt/guile.git] / module / rnrs / lists.scm
1 ;;; lists.scm --- The R6RS list utilities library
2
3 ;; Copyright (C) 2010 Free Software Foundation, Inc.
4 ;;
5 ;; This library is free software; you can redistribute it and/or
6 ;; modify it under the terms of the GNU Lesser General Public
7 ;; License as published by the Free Software Foundation; either
8 ;; version 3 of the License, or (at your option) any later version.
9 ;;
10 ;; This library is distributed in the hope that it will be useful,
11 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ;; Lesser General Public License for more details.
14 ;;
15 ;; You should have received a copy of the GNU Lesser General Public
16 ;; License along with this library; if not, write to the Free Software
17 ;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 \f
19
20 (library (rnrs lists (6))
21 (export find for-all exists filter partition fold-left fold-right remp remove
22 remv remq memp member memv memq assp assoc assv assq cons*)
23 (import (rnrs base (6))
24 (only (guile) filter member memv memq assoc assv assq cons*)
25 (rename (only (srfi srfi-1) fold
26 any
27 every
28 remove
29 member
30 assoc
31 find
32 partition
33 fold-right
34 filter-map)
35 (fold fold-left)
36 (any exists)
37 (every for-all)
38 (remove remp)
39
40 (member memp-internal)
41 (assoc assp-internal)))
42
43 (define (remove obj list) (remp (lambda (elt) (equal? obj elt)) list))
44 (define (remv obj list) (remp (lambda (elt) (eqv? obj elt)) list))
45 (define (remq obj list) (remp (lambda (elt) (eq? obj elt)) list))
46
47 (define (memp pred list) (memp-internal #f list (lambda (x y) (pred y))))
48 (define (assp pred list) (assp-internal #f list (lambda (x y) (pred y))))
49 )