caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] OCaml error message
@ 2004-05-03 18:19 Holger Schulz
  2004-05-03 18:38 ` Jean-Baptiste Rouquier
  2004-05-03 18:42 ` Matt Gushee
  0 siblings, 2 replies; 4+ messages in thread
From: Holger Schulz @ 2004-05-03 18:19 UTC (permalink / raw)
  To: caml-list

I've following declarations

---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---

Thanks

hs

-- 
"Sie haben neue Mails!" - Die GMX Toolbar informiert Sie beim Surfen!
Jetzt aktivieren unter http://www.gmx.net/info

-------------------
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


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

* Re: [Caml-list] OCaml error message
  2004-05-03 18:19 [Caml-list] OCaml error message Holger Schulz
@ 2004-05-03 18:38 ` Jean-Baptiste Rouquier
  2004-05-03 18:42 ` Matt Gushee
  1 sibling, 0 replies; 4+ messages in thread
From: Jean-Baptiste Rouquier @ 2004-05-03 18:38 UTC (permalink / raw)
  To: Holger Schulz; +Cc: caml-list

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


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

* Re: [Caml-list] OCaml error message
  2004-05-03 18:19 [Caml-list] OCaml error message Holger Schulz
  2004-05-03 18:38 ` Jean-Baptiste Rouquier
@ 2004-05-03 18:42 ` Matt Gushee
  1 sibling, 0 replies; 4+ messages in thread
From: Matt Gushee @ 2004-05-03 18:42 UTC (permalink / raw)
  To: caml-list

On Mon, May 03, 2004 at 08:19:19PM +0200, Holger Schulz wrote:
> I've following declarations
> 
> ---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?

> This expression is not a function, it cannot be applied

Sure. Syntactically speaking, the expression 'm div g' appears to be a
call to function 'm' with arguments 'div' and 'g'. Of course, this
doesn't work because 'm' is an integer.

But actually I think your confusion is elsewhere. It looks like you were
trying to use 'div' as a binary operator; as far as I know, there is no
such operator. Try 'm / g' instead.

By the way, when you get error messages like this, it is helpful to pay
close attention to the *exact* position of the error--e.g., in this
case, the message gave a range of characters pointing to 'm' (and maybe
that character was underlined in the toplevel, too), so you know that
the toplevel or compiler expected 'm' to be a function.

-- 
Matt Gushee                 When a nation follows the Way,
Englewood, Colorado, USA    Horses bear manure through
mgushee@havenrock.com           its fields;
http://www.havenrock.com/   When a nation ignores the Way,
                            Horses bear soldiers through
                                its streets.
                                
                            --Lao Tzu (Peter Merel, trans.)

-------------------
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


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

* [Caml-list] OCaml error message
@ 2004-05-03 18:19 Holger Schulz
  0 siblings, 0 replies; 4+ messages in thread
From: Holger Schulz @ 2004-05-03 18:19 UTC (permalink / raw)
  To: caml-list

I've following declarations

---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---

Thanks

hs

-- 
"Sie haben neue Mails!" - Die GMX Toolbar informiert Sie beim Surfen!
Jetzt aktivieren unter http://www.gmx.net/info

-------------------
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


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

end of thread, other threads:[~2004-05-03 18:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-03 18:19 [Caml-list] OCaml error message Holger Schulz
2004-05-03 18:38 ` Jean-Baptiste Rouquier
2004-05-03 18:42 ` Matt Gushee
2004-05-03 18:19 Holger Schulz

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).