Does Reason memoize pure functions?


#1

I’m curious b/c I’m working on a math typesetting layout algorithm in which getWidth and getHeight are recursively called on children. The children are laid out first which means that getWidth and getHeight could be called repeated on with the same args many time. I’d like to avoid redundant computation and am curious what support there might be for memoization within Reason.


#2

You can use lazy to memoize computations: https://realworldocaml.org/v1/en/html/imperative-programming-1.html#laziness-and-other-benign-effects


#3

Actually, I got this wrong, you have to implement memoization yourself, see further down https://realworldocaml.org/v1/en/html/imperative-programming-1.html#memoization-and-dynamic-programming. Laziness is different.