Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Function definition with multiple patterns in multiple equations
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Clement Renard <Clement.Renard@i...>
Subject: Re: [Caml-list] Function definition with multiple patterns in multiple equations
On Tue, 8 Jan 2002, José Romildo Malaquias wrote:

> Hello.
> 
> I am trying to define a function in OCaml with multiple equations (rules)
> and multiple patterns in each equation. I have tried the 3 forms below,
> without success.
> 
> 	let f 0 0 = 1
> 	  | f _ _ = 0
> 
> 	let f = fun 0 0 -> 1
>           | _ _ -> 0
> 
> 	let f = function 0 0 -> 1
> 	  | _ _ -> 0
> 
> None of them seems to be supported by the language. In SML, one can write
> 
> 	fun f 0 0 = 1
> 	  | f _ _ = 0
> 
> What is the equivalent in OCaml?

For example :

let f x y = match x,y with
 0,0 -> 1
|_,_ -> 0 


Clement Renard

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