memoize

open fun <T, R> memoize(function: (T) -> R): (T) -> R