This project is read-only.
Using .filter

Functions - Arrays, Lists, Seqs
Description: .filter applies a given function to the collection, returning only those elements for which the given predicate returns true.
let AggregateExample4() =
let names = [|"Bob"; "Jim"; "Stephen"; "James"; "Fred"; "Will"; "Brian"; "David"; "Mark"; "Jonathan"|]
let longNames = Array.filter (fun (x: string) -> x.Length > 4) names

printfn "names = %A\n" names
printfn "longNames = %A" longNames

Execution Result:
names = [|"Bob"; "Jim"; "Stephen"; "James"; "Fred"; "Will"; "Brian"; "David"; "Mark";

longNames = [|"Stephen"; "James"; "Brian"; "David"; "Jonathan"|]

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


No comments yet.