documented new scheme/list functions
svn: r9426
This commit is contained in:
parent
7262a7a19d
commit
b62fef320b
|
@ -480,7 +480,8 @@ Like @scheme[assoc], but finds an element using the predicate
|
||||||
|
|
||||||
@note-lib[scheme/list]
|
@note-lib[scheme/list]
|
||||||
@(define list-eval (make-base-eval))
|
@(define list-eval (make-base-eval))
|
||||||
@interaction-eval[#:eval list-eval (require scheme/list)]
|
@(interaction-eval #:eval list-eval
|
||||||
|
(require scheme/list (only-in scheme/function negate)))
|
||||||
|
|
||||||
@defthing[empty null?]{The empty list.}
|
@defthing[empty null?]{The empty list.}
|
||||||
|
|
||||||
|
@ -512,6 +513,9 @@ Like @scheme[assoc], but finds an element using the predicate
|
||||||
|
|
||||||
@defproc[(last [lst list?]) any]{Returns the last element of the list.}
|
@defproc[(last [lst list?]) any]{Returns the last element of the list.}
|
||||||
|
|
||||||
|
@defproc[(last-pair [p pair?]) pair?]{
|
||||||
|
Returns the last pair of a (possibly improper) list.}
|
||||||
|
|
||||||
@defproc[(drop [lst any/c] [pos nonnegative-exact-integer?]) list?]{
|
@defproc[(drop [lst any/c] [pos nonnegative-exact-integer?]) list?]{
|
||||||
Synonym for @scheme[list-tail].
|
Synonym for @scheme[list-tail].
|
||||||
}
|
}
|
||||||
|
@ -569,6 +573,35 @@ traversal.
|
||||||
(flatten 'a)
|
(flatten 'a)
|
||||||
]}
|
]}
|
||||||
|
|
||||||
|
@defproc[(remove-duplicates [lst list?] [proc procedure? equal?])
|
||||||
|
list?]{
|
||||||
|
Returns a list that has all items in @scheme[lst], but without
|
||||||
|
duplicate items. The resulting list is in the same order as
|
||||||
|
@scheme[lst], and for any item that occurs multiple times, the first
|
||||||
|
one is kept. @scheme[proc] is used for comparing items.
|
||||||
|
|
||||||
|
@examples[#:eval list-eval
|
||||||
|
(remove-duplicates '(a b b a))
|
||||||
|
]}
|
||||||
|
|
||||||
|
@defproc[(filter-map [proc procedure?] [lst list?] ...+)
|
||||||
|
list?]{
|
||||||
|
Like @scheme[map], but the resulting list does not contain any
|
||||||
|
@scheme[#f] values. In other words, @scheme[(filter-map p lst)] is
|
||||||
|
like @scheme[(filter (lambda (x) x) (map p lst))], except that it is
|
||||||
|
more efficient since no intermediate list is built.}
|
||||||
|
|
||||||
|
@defproc[(partition [proc procedure?] [lst list?])
|
||||||
|
list?]{
|
||||||
|
Similar to @scheme[filter], except that two values are returned: the
|
||||||
|
items that satisfied the given @scheme[proc] predicate, and the items
|
||||||
|
that did not satisfy it. It is slightly more efficient than
|
||||||
|
@scheme[(values (filter proc lst) (filter (negate proc lst)))].
|
||||||
|
|
||||||
|
@examples[#:eval list-eval
|
||||||
|
(partition even? '(1 2 3 4 5 6))
|
||||||
|
]}
|
||||||
|
|
||||||
@; ----------------------------------------
|
@; ----------------------------------------
|
||||||
@section{Immutable Cyclic Data}
|
@section{Immutable Cyclic Data}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user