import math._ def f(x:Double):Double={ // 3*x*x+x // or 3*math.pow(3,2)+x sin(x) } clear val (s, e, step)= (-10.0, 10.0, 0.1) val (sx, sy) = (10, 100) val (tx, ty) = (newTurtle, newTurtle) runInBackground { tx.jumpTo(s*sx,0) ; tx.moveTo(e*sx,0) } runInBackground { ty.jumpTo(0,-1*sy) ty.moveTo(0,sy*(s to e by step).map(f).max) } jumpTo(s*sx,f(s)*sy) for(x <- s to e by step) moveTo(x*sx,f(x)*sy)