We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I had resolved the problem using a Map as the memo. Because the memo would be changed during evaluating, I had to use State pattern as well. This made the solution somehow complicated.
Then I realized the max size is pre-defined. Thus we can use Vector to store all the possible results.
BTW, I like this generator. It could be used as the data source for the Vector.
Pentagonal Numbers
You are viewing a single comment's thread. Return to all comments →
With Haskell
I had resolved the problem using a Map as the memo. Because the memo would be changed during evaluating, I had to use State pattern as well. This made the solution somehow complicated. Then I realized the max size is pre-defined. Thus we can use Vector to store all the possible results. BTW, I like this generator. It could be used as the data source for the Vector.
After that, the solution became much shorter and quite elegant. `