Browse thread
[Caml-list] Function definition with multiple patterns in multiple equations
[
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: | Remi VANICAT <vanicat@l...> |
| Subject: | Re: [Caml-list] Function definition with multiple patterns in multiple equations |
José Romildo Malaquias <romildo@uber.com.br> 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