You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 30, 2026. It is now read-only.
function-tree defines a class called SingleVariableFunction that constructs a function-like object from a string representation of a single variable function.
final f =SingleVariableFunction(fromExpression:'3 * cosh(x)');
print(f(3));
30.202985987333292
By default, 'x' is taken to be the variable; if this is not what we want, we can state the name of the variable:
final f =SingleVariableFunction(
fromExpression:'3 * cosh(a)',
withVariable:'a'
);
print(f(3));
30.202985987333292
A more succinct way to construct a SingleVariableFunction instance is directly from a string:
final f ='3 * x'.toSingleVariableFunction();
print(f(100));