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: José_Romildo_Malaquias <romildo@u...>
Subject: [Caml-list] Function definition with multiple patterns in multiple equations
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?

Romildo
-- 
Prof. José Romildo Malaquias               Departamento de Computação
http://iceb.ufop.br/~romildo       Universidade Federal de Ouro Preto
romildo@iceb.ufop.br                                           Brasil
romildo@uber.com.br
-------------------
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