in reply to Code Generation with Perl?
Nonetheless, it's usually considered a bad idea to generate code if you can do it someway else. Consider using anonymous subs instead. Steffenuse Math::Symbolic qw/:all/; my $function = parse_from_string( 'partial_derivative(A*sin(omega*t), t)' ); my ($closure) = $function->apply_derivatives()->to_sub(); print $closure->(5, 3, 1); # A=5, omega=3, t=1 my ($code) = $function->apply_derivatives()->to_code(); print $function->to_latex(replace_default_greek => 1);
|
|---|