Q:

How to create a histogram from a 2d array F#

How would I create a histogram from a 2d array in F#.
I have tried something like this:
let histogram =
    Array.iter (fun acc fs -> 
        fs |> List.iter (fun k -> 
            if Map.containsKey k acc
            then Map.add k (acc.[k] + 1) acc
            else Map.add k 1 acc
        )
    ) Map.empty

But I really cannot get my head around how to solve this.
Any suggestions to kickstart me?

A:

If i you right understand:
let arr = [| [|1; 2; 4 |] ;[|3; 2; 4 |] ;[|1; 7; 4 |] |]
arr |> Array.concat |> Array.sort |> Seq.groupBy id |> Seq.map(fun el -> fst el,Seq.length (snd el)) 
|> Seq.iter(fun x -> printfn "%d [%d]" (fst x) (snd x)))

Out:
1 [2]
2 [2]
3 [1]
4 [3]
7 [1]

http://ideone.com/P5hmtU

