Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let crimeService = new DataGovCrimeByCitiesService(key, userId)
- let states = [
- "Alabama";"Alaska";"Arizona";"Arkansas";"California";"Colorado";"Connecticut";
- "Delaware";"District of Columbia";"Florida";"Georgia";"Hawaii";"Idaho";
- "Illinois";"Indiana";"Iowa";"Kansas";"Kentucky";"Louisiana";"Maine";
- "Maryland";"Massachusets";"Michigan";"Minnesota";"Mississippi";"Missouri";
- "Montana";"Nebraska";"Nevada";"New Hampshire";"New Mexico";"New Jersey";"New York";
- "Oregon";"Oklahoma";"Ohio";"North Carolina";"North Dakota";"Pennsylvania";
- "Rhode Island";"South Carolina";"South Dakota";"Tennessee";"Texas";"Utah";
- "Vermont";"Virginia";"Washington";"West Virginia";"Wisconsin";"Wyoming"]
- let allData =
- states.AsParallel()
- |> Seq.map (fun(s) -> crimeService.Invoke(s,null,null).AsEnumerable())
- |> Seq.reduce (fun(crimedata) -> crimedata |> (fun x y -> Seq.append x y))
- let leadingForMurder =
- allData
- |> Seq.filter (fun(c) -> c.MurderAndNonEgligentManslaughter > 0)
- |> Seq.filter (fun(c) -> c.Population > 10000)
- |> Seq.maxBy (fun(c) -> (decimal c.MurderAndNonEgligentManslaughter) / (decimal c.Population))
- printfn "The city with the highest murder rate relative to it's population is:"
- printfn "%s, %s"
- leadingForMurder.City
- leadingForMurder.State
- printfn "with %d murders and a population of %d people"
- leadingForMurder.MurderAndNonEgligentManslaughter
- leadingForMurder.Population
- Console.ReadKey() |> ignore
Add Comment
Please, Sign In to add comment