mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-01-18 05:59:14 +01:00
Merge pull request #2208 from juan70/ocaml-filter
Change anonymous function in List.filter example
This commit is contained in:
commit
de993590ac
@ -216,7 +216,7 @@ List.nth my_list 1 ;;
|
||||
|
||||
(* There are higher-order functions for lists such as map and filter. *)
|
||||
List.map (fun x -> x * 2) [1; 2; 3] ;;
|
||||
List.filter (fun x -> if x mod 2 = 0 then true else false) [1; 2; 3; 4] ;;
|
||||
List.filter (fun x -> x mod 2 = 0) [1; 2; 3; 4] ;;
|
||||
|
||||
(* You can add an item to the beginning of a list with the "::" constructor
|
||||
often referred to as "cons". *)
|
||||
|
Loading…
x
Reference in New Issue
Block a user