A classic mechanism for functional programs to implement DP is via lazy evaluation – so all the subproblems are not evaluated until they are needed. Furthermore, a local state is usually required to cache solutions to each evaluated subproblem.
In q, however, neither lazy evaluation nor local state is possible. I could implement a DP algorithm using global state (as in a global variable), but that prevents my DP algorithm from being parallelized – since non-main threads are not allowed to make global modifications.
Does any one have experience/idea regarding efficient implementation of DP algorithms using q?