imemo1<A, R> function
Checks 1 argument for equality with identical call and returns the cached result if it was not changed.
Implementation
Func1<A, R> imemo1<A, R>(Func1<A, R> func) {
late A prevArg;
late R prevResult;
bool isInitial = true;
return ((A arg) {
if (!isInitial && identical(arg, prevArg)) {
return prevResult;
} else {
prevArg = arg;
prevResult = func(arg);
isInitial = false;
return prevResult;
}
});
}