Using dynamic programming in Haskell? [Warning: ProjectEuler 31 solution inside]
问题 In solving projecteuler.net's problem #31 [ SPOILERS AHEAD ] (counting the number of ways to make 2£ with the British coins), I wanted to use dynamic programming. I started with OCaml, and wrote the short and very efficient following programming: open Num let make_dyn_table amount coins = let t = Array.make_matrix (Array.length coins) (amount+1) (Int 1) in for i = 1 to (Array.length t) - 1 do for j = 0 to amount do if j < coins.(i) then t.(i).(j) <- t.(i-1).(j) else t.(i).(j) <- t.(i-1).(j) +