caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* RE: [Caml-list] function type confusion (using let)
@ 2001-09-03  6:26 FALCON Gilles FTRD/DTL/LAN
  0 siblings, 0 replies; 7+ messages in thread
From: FALCON Gilles FTRD/DTL/LAN @ 2001-09-03  6:26 UTC (permalink / raw)
  To: 'Laurent Chéno', Michael Leary; +Cc: Caml-list



-----Message d'origine-----
De : Laurent Chéno [mailto:laurent.cheno@noos.fr]
Envoyé : lundi 3 septembre 2001 07:55
À : Michael Leary
Cc : Caml-list
Objet : Re: [Caml-list] function type confusion (using let)


(* please excuse my poor english *)

> 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
>       x
>   else if x < 0.0 then
                      ^ this "then" has no else !

>     if x < -.pi then  (* <------ here *)
>       pi2 +. x
>     else
>       x

... else ??

You have forgotten the "else" clause : if <cond> then <expr>   has 
type : unit
if <cond> then <float-expr> else <float-expr> has type : 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
-------------------
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


^ permalink raw reply	[flat|nested] 7+ messages in thread
* [Caml-list] function type confusion (using let)
@ 2001-09-03  5:25 Michael Leary
  2001-09-03  5:46 ` Patrick M Doane
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Michael Leary @ 2001-09-03  5:25 UTC (permalink / raw)
  To: caml

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
      x
  else if x < 0.0 then
    if x < -.pi then  (* <------ here *)
      pi2 +. x
    else
      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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2001-09-04  4:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-03  6:26 [Caml-list] function type confusion (using let) FALCON Gilles FTRD/DTL/LAN
  -- strict thread matches above, loose matches on Subject: below --
2001-09-03  5:25 Michael Leary
2001-09-03  5:46 ` Patrick M Doane
2001-09-03  5:53   ` Michael Leary
2001-09-03  5:51 ` Michael Leary
2001-09-04  4:51   ` ITO Tsuyoshi
2001-09-03  5:55 ` Laurent Chéno

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).