From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA05718; Tue, 8 Jan 2002 14:30:31 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA05498 for ; Tue, 8 Jan 2002 14:30:30 +0100 (MET) Received: from serveur3.labri.fr (serveur3.labri.u-bordeaux.fr [147.210.8.180]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g08DUT112323 for ; Tue, 8 Jan 2002 14:30:30 +0100 (MET) Received: (from vanicat@localhost) by serveur3.labri.fr (8.11.6/8.11.6) id g08DUPE19200; Tue, 8 Jan 2002 14:30:25 +0100 X-Authentication-Warning: serveur3.labri.fr: vanicat set sender to vanicat@labri.u-bordeaux.fr using -f To: caml-list@inria.fr Subject: Re: [Caml-list] Function definition with multiple patterns in multiple equations References: <20020108110836.A9147@darling.home.br> From: Remi VANICAT In-Reply-To: <20020108110836.A9147@darling.home.br> Date: 08 Jan 2002 14:30:25 +0100 Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.0.104 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk José Romildo Malaquias writes: > 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 > > > What is the equivalent in OCaml? let f x y = match (x, y) with | 0, 0 -> 1 | _ -> 0 by the way, the compiler make the obvious optimization (it doesn't build the tuple) -- Rémi Vanicat vanicat@labri.u-bordeaux.fr http://dept-info.labri.u-bordeaux.fr/~vanicat ------------------- 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