[
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: | Jean-Baptiste Rouquier <jrouquie@e...> |
| Subject: | Re: [Caml-list] OCaml error message |
Replace "div" with "/".
By the way, you don't need to write the types of the functions : just write
let rec ggT (x,y) =
if y = 0 then x
else ggT (y, x mod y)
and rely on type inference.
There is also a beginer's list :
http://groups.yahoo.com/group/ocaml_beginners/.
Regards,
Jean-Baptiste Rouquier
http://perso.ens-lyon.fr/jean-baptiste.rouquier
>---cut---
>type rat = int * int;;
>
>exception Denominator_Zero;;
>
>let rec ggT : (int * int) -> int = fun (x,y) -> if y = 0 then x else ggT
>(y, x mod y)
>
>let kgV : int * int -> int = fun (x,y) -> (x / ggT (x,y)) * y
>
>let kuerze : rat -> rat = function (m,n) -> if n = 0 then raise
>Denominator_Zero
> else let g=ggT (m,n) in (m div g,n div g)
>---cut---
>
>Loading it with #use give the following error message, which I do not
>understand. Could anyone help me?
>
>---cut--
># #use "B2A3.ml";;
>type rat = int * int
>exception Denominator_Zero
>val ggT : int * int -> int = <fun>
>val kgV : int * int -> int = <fun>
>File "B2A3.ml", line 10, characters 29-30:
>This expression is not a function, it cannot be applied
>---cut---
>
-------------------
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/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners