2D dynamic programming in F#
===

I need to implement a simple dynamic programming algorithm in 2D in F#. For simple 1D cases Seq.unfold seems to be the way to go, see e.g. http://stackoverflow.com/a/7986083/5363

Is there a nice (and efficient) way to achieve a similar result in 2D, e.g. rewrite the following pseudo-code in functional style:

      let alpha = 
        let result = Array2D.zeroCreate N T
        for i in 0 .. N-1 do
          result.[0, i] <- (initialPi i) * (b i observations.[0])
        for t in 1 .. T-1 do
          for i in 0 .. N-1 do
            let s = row t-1 result |> Seq.mapi (fun j alpha_t_j -> alpha_t_j * initialA.[i, j]) () |> Seq.sum
            result.[t, i] <- s * (b i observations.[t])
        result 

assume that all the missing functions and arrays are defined above.