(********************************************************************) (* OCaml code from the book ``Learn Programming with OCaml'' *) (* See https://usr.lmf.cnrs.fr/lpo/ *) (* *) (* Sylvain Conchon and Jean-Christophe Filliâtre *) (* Copyright 2025 Université Paris-Saclay and CNRS *) (* *) (* Openly licensed via CC BY SA 4.0 *) (* See https://creativecommons.org/licenses/by-sa/4.0/deed.en *) (********************************************************************) (* Program 3 on page 28 Drawing a Cardioid *) open Graphics let () = open_graph " 300x200" let () = moveto 200 150; for i = 0 to 200 do let th = atan 1. *. float i /. 25. in let r = 50. *. (1. -. sin th) in lineto (150 + truncate (r *. cos th)) (150 + truncate (r *. sin th)) done; ignore (read_key ())
This document was generated using caml2html