If it's really data and can be done once, put it in the transformed data block.
"Memoization" is the word for storing intermediate computations for reuse. If you look at the HMM dynamic programming algorithm (the "forward" algorithm), that uses a kind of memoization to turn what would be a naive exponential algorithm into a linear one.
I don't think we want to have stateful functions.
What I do think we want longer term is closures, so that we don't have to bother reshaping variables but can just access them as defined in the data block or parameters block from within functions. That's also hard to reason about, but I don't think it's quite as nasty as having stateful functions.