* Added filter.
This commit is contained in:
parent
4b83f21480
commit
66541809e1
BIN
src/ikarus.boot
BIN
src/ikarus.boot
Binary file not shown.
|
@ -2,13 +2,13 @@
|
|||
(library (ikarus lists)
|
||||
(export $memq list? list cons* make-list append length list-ref reverse
|
||||
last-pair memq memp memv member assq assp assv assoc
|
||||
remq remv remove remp map for-each andmap ormap list-tail)
|
||||
remq remv remove remp filter map for-each andmap ormap list-tail)
|
||||
(import
|
||||
(ikarus system $fx)
|
||||
(ikarus system $pairs)
|
||||
(except (ikarus) list? list cons* make-list append reverse
|
||||
last-pair length list-ref memq memp memv member assq
|
||||
assp assv assoc remq remv remove remp
|
||||
assp assv assoc remq remv remove remp filter
|
||||
map for-each andmap ormap list-tail))
|
||||
|
||||
(define $memq
|
||||
|
@ -391,7 +391,7 @@
|
|||
(race x ls ls ls))))
|
||||
|
||||
|
||||
(module (remq remv remove remp)
|
||||
(module (remq remv remove remp filter)
|
||||
(define-syntax define-remover
|
||||
(syntax-rules ()
|
||||
[(_ name cmp check)
|
||||
|
@ -432,7 +432,11 @@
|
|||
(define-remover remp (lambda (elt p) (p elt))
|
||||
(lambda (x ls)
|
||||
(unless (procedure? x)
|
||||
(error 'remp "~s is not a procedure" x)))))
|
||||
(error 'remp "~s is not a procedure" x))))
|
||||
(define-remover filter (lambda (elt p) (not (p elt)))
|
||||
(lambda (x ls)
|
||||
(unless (procedure? x)
|
||||
(error 'filter "~s is not a procedure" x)))))
|
||||
|
||||
|
||||
(module (map)
|
||||
|
|
|
@ -332,6 +332,7 @@
|
|||
[remp i]
|
||||
[remv i]
|
||||
[remove i]
|
||||
[filter i]
|
||||
[list-sort i]
|
||||
[vector-sort i]
|
||||
[vector-sort! i]
|
||||
|
|
|
@ -504,7 +504,7 @@
|
|||
[assq C ls se]
|
||||
[assv C ls se]
|
||||
[cons* C ls]
|
||||
[filter S ls]
|
||||
[filter C ls]
|
||||
[find S ls]
|
||||
[fold-left S ls]
|
||||
[fold-right S ls]
|
||||
|
@ -516,9 +516,9 @@
|
|||
[memv C ls se]
|
||||
[partition S ls]
|
||||
[remq C ls]
|
||||
[remp S ls]
|
||||
[remv S ls]
|
||||
[remove S ls]
|
||||
[remp C ls]
|
||||
[remv C ls]
|
||||
[remove C ls]
|
||||
;;;
|
||||
[set-car! C mp se]
|
||||
[set-cdr! C mp se]
|
||||
|
@ -792,12 +792,6 @@
|
|||
libs))))
|
||||
(error #f "invalid id ~s" x)))
|
||||
|
||||
(define (filter p? ls)
|
||||
(cond
|
||||
[(null? ls) '()]
|
||||
[(p? (car ls))
|
||||
(cons (car ls) (filter p? (cdr ls)))]
|
||||
[else (filter p? (cdr ls))]))
|
||||
|
||||
(define (filter* ls)
|
||||
(filter
|
||||
|
|
Loading…
Reference in New Issue