Functional Programming & Proofs

back - prev - next

Complement

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

  1. What about variations ? (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.map (fun ((x2,y2),(x1,y1)) -> (x2,(y2-y1)/(x2-x1)))
|> List.map (fun (x,y)->string x+","+string y+"\n")
|> List.fold (+) ""
|> fun r -> File.WriteAllText("derivate.csv",r);;