This project is read-only.
Lists and Filter

Category:
Lists, Tuples and Options
Description: This sample shows how to filter a list
Code:
let ListSample6() =
let data = [("Cats",4);
("Dogs",5);
("Mice",3);
("Elephants",2)]
let res = data |> List.filter (fun (nm,x) -> nm.Length <= 4)
printfn "Animals with short names: %A" res


Execution Result:
Animals with short names: [("Cats", 4); ("Dogs", 5); ("Mice", 3)]

Last edited Sep 14, 2011 at 3:51 AM by ttliu2000, version 1

Comments

Michuki Nov 30, 2014 at 1:01 PM 
Thanks for this :)