This package help you to convert recursive function into the while-loop codes. so that program won't meet out of memory that caused by stack overflow. inspired by kotlin tailrec
keywords. (https://kotlinlang.org/docs/functions.html#tail-recursive-functions)
If you like my module, please buy me a coffee.
More and more tiny and useful GitHub action modules are on the way. Please donate to me. I accept a part-time job contract. if you need, please contact me: zhang_nan_163@163.com
Math concepts 高中数学中的函数"不动点"
import 'dart:core';
import 'package:tailrec/tailrec.dart';
import 'dart:math';
final eps = 1E-10; //precision
void main() {
final firstValue = 1;
var tailrec = Tailrec(
conditionCallback: <double>(dynamic x) {
final y = cos(x);
final temp = (x - y).abs();
return temp < eps;
},
recurringParamComputeCallback: <double>(dynamic x) {
return cos(x) as double;
},
resultCallback: <double>(dynamic x) {
return x;
},
);
final fixedPoint = tailrec.apply(firstValue);
print(fixedPoint);
}
PalPal: https://paypal.me/nzhang4