Fix discussion of filter.
Closes PR 15083.
This commit is contained in:
parent
110f1bd9b0
commit
4c04d4afce
|
@ -74,15 +74,7 @@ by @racket[and]ing or @racket[or]ing:
|
||||||
(ormap number? (list "a" "b" 6))
|
(ormap number? (list "a" "b" 6))
|
||||||
]
|
]
|
||||||
|
|
||||||
The @racket[filter] function keeps elements for which the body result
|
The @racket[map], @racket[andmap], and @racket[ormap]
|
||||||
is true, and discards elements for which it is @racket[#f]:
|
|
||||||
|
|
||||||
@interaction[
|
|
||||||
(filter string? (list "a" "b" 6))
|
|
||||||
(filter positive? (list 1 -2 6 7 0))
|
|
||||||
]
|
|
||||||
|
|
||||||
The @racket[map], @racket[andmap], @racket[ormap], and @racket[filter]
|
|
||||||
functions can all handle multiple lists, instead of just a single
|
functions can all handle multiple lists, instead of just a single
|
||||||
list. The lists must all have the same length, and the given function
|
list. The lists must all have the same length, and the given function
|
||||||
must accept one argument for each list:
|
must accept one argument for each list:
|
||||||
|
@ -93,6 +85,14 @@ must accept one argument for each list:
|
||||||
(list 6 3 7))
|
(list 6 3 7))
|
||||||
]
|
]
|
||||||
|
|
||||||
|
The @racket[filter] function keeps elements for which the body result
|
||||||
|
is true, and discards elements for which it is @racket[#f]:
|
||||||
|
|
||||||
|
@interaction[
|
||||||
|
(filter string? (list "a" "b" 6))
|
||||||
|
(filter positive? (list 1 -2 6 7 0))
|
||||||
|
]
|
||||||
|
|
||||||
The @racket[foldl] function generalizes some iteration functions. It
|
The @racket[foldl] function generalizes some iteration functions. It
|
||||||
uses the per-element function to both process an element and combine
|
uses the per-element function to both process an element and combine
|
||||||
it with the ``current'' value, so the per-element function takes an
|
it with the ``current'' value, so the per-element function takes an
|
||||||
|
|
Loading…
Reference in New Issue
Block a user