Question: This is in Ocaml Write a function filter: (a -> bool) -> a list -> a list. The call filter f l should return l
This is in Ocaml
Write a function filter: (a -> bool) -> a list -> a list. The call filter f l should return l with all and only the items for which f returns true; these items should appear in the same order in which they appear in the original list. Some examples:
filter (fun x -> x > 2) [5; 3; 1; 2; 4] = [5; 3; 4]
filter (fun x -> x > 5) [5; 3; 1; 2; 4] = []
Will thumb up thanks!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
