(filter procedure list)
appliesprocedure
to each element oflist
and returns a new list containing only the elements for whichprocedure
returns true.
(R. Kent Dybvig The Scheme Programming Language) (online)
What may not be apparent from this description is that, while the elements in the returned
list occur in the same order as in list
, the order of calls of procedure
is not
specified in R6RS. (Racket, however, applies the procedure "to each element from first to last")
A recently active answer
mentions that it requires a filterfunc
which works over its argument list
in order. How should one write this function?
An answer with my explanation of the issue is supplied.
It involves you should not use mutation of some external variable inside procedure and it supposes the implementation may apply parallelism, for example map-reduce.