English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] function type confusion (using let)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-09-03 (05:26)
From: Michael Leary <leary@n...>
Subject: [Caml-list] function type confusion (using let)
I was trying to be clever about not using ;; and minimizing my use of ; in
files, and I've gone off the deep end...

Why is this wrong, and how do I fix it?:

let pi = 3.14159
let pi2 = 2.0 *. pi

let normr r =
  let x = mod_float r pi2 in
  if x > 0.0 then
    if x > pi then
      -.pi2 +. x
  else if x < 0.0 then
    if x < -.pi then  (* <------ here *)
      pi2 +. x

File "fbot.ml", line 118, characters 4-52:
This expression has type float but is here used with type unit

I want normr to be float -> float

Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr