define memoized procedure easily in Ruby