Use getOrElseUpdate to simplify Memo implementation for mutable maps