Functional Programming & Proofs

prev - back

Complement

Try to understand "intuitively" what the following code do.

  1. What about solution f(x)=0 ? Optimum with derivative ?
let dta = [-3.0..0.1..3.0] |> map (fun x->(x,x*(x+1.0)));;
List.zip (dta.[1..length dta-1]) (dta.[0..List.length dta-2])
|> List.filter (fun ((x2,y2),(x1,y1)) -> y1*y2<0.0)
|> List.map (fun ((x2,y2),(x1,y1)) -> (x1,x2))
|> List.iter (fun (x1,x2) -> printfn "Solution between %f and %f" x1 x2);;

Solution between -1.020000 and -0.990000