class EulerMethod { T0 : static : Float; TR : static : Float; k : static : Float; delta_t : static : Float[]; n : static : Float; function : Main(args : String[]) ~ Nil { T0 := 100; TR := 20; k := 0.07; delta_t := [2.0, 5.0, 10.0]; n := 100; f := NewtonCooling(Float) ~ Float; for(i := 0; i < delta_t->Size(); i+=1;) { IO.Console->Print("delta_t = ")->PrintLine(delta_t[i]); Euler(f, T0, n->As(Int), delta_t[i]); }; } function : native : NewtonCooling(t : Float) ~ Float { return -1 * k * (t-TR); } function : native : Euler(f : (Float) ~ Float, y : Float, n : Int, h : Float) ~ Nil { for(x := 0; x<=n; x+=h;) { IO.Console->Print("\t")->Print(x)->Print("\t")->PrintLine(y); y += h * f(y); }; } }