Browse thread
[Caml-list] function type confusion (using let)
-
Michael Leary
- Patrick M Doane
- Michael Leary
- Laurent_Chéno
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Laurent_Chéno <laurent.cheno@n...> |
| Subject: | 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