in reply to Re^6: Closures and undefined subs
in thread Closures and undefined subs
Failures are described in another post earlier if I try lexical or local.package Levels::Level_IV; use strict; use warnings; use Math::RungeKutta; ... sub level_iv { my ( $args_ref, $R, $factor, $level_iii_ref ) = @_; ... for my $i ( $t..$t_final ) { ... ( $t, $dt, @y_med ) = rk4_auto( \@y_med, \&_dydt, $t, $dt, $eps + ); } ... sub _equation_air { my ( $args_ref, $level_iii_ref, $y ) = @_; #I tried these options # # my $_equation_air = sub { # my $y = shift; # local *_equation_air = sub { # my $y = shift; #for easy calculations make copies of the parameters (not alia +ses) my arguments for formula from $args_ref and $level_iii_ref #differential equation for mass my $dydt = some formula; return $dydt; }; ... #differential equation for fugacity at start and end times sub _dydt { my ( $t, @y ) = @_; my @dydt; #start differentiation at point y0 (air) $dydt[0] = _equation_air( $args_ref, $level_iii_ref, $y[0] ); #tried these #$dydt[0] = _equation_air($y[0]); #local #$dydt[0] = $_equation_air->($y[0]);#lexical ... return @dydt; } ... return some hash; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: Closures and undefined subs
by ikegami (Patriarch) on Sep 26, 2007 at 19:17 UTC | |
by KaiAllard_ (Initiate) on Sep 26, 2007 at 20:42 UTC | |
by ikegami (Patriarch) on Sep 26, 2007 at 21:09 UTC |