Browse thread
[Caml-list] Pattern matching missing (or brain damage?)
-
Alessandro Baretta
- William Lovas
- Michael Vanier
[
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: | Michael Vanier <mvanier@c...> |
| Subject: | Re: [Caml-list] Pattern matching missing (or brain damage?) |
# type ex = A of int | B of int | C of int | D of int | E of int;;
type ex = A of int | B of int | C of int | D of int | E of int
# let a = A 1000;;
val a : ex = A 1000
# match a with
A(_) | B(_) | C(_) -> "foo"
| C(_) | D(_) | E(_) -> "bar";;
- : string = "foo"
You put in an extra | before the A(_).
Mike
> Date: Fri, 19 Jul 2002 00:22:44 +0200
> From: Alessandro Baretta <alex@baretta.com>
>
> I believe I remember a pattern matching construct where an
> expression could be associated with multiple patterns.
>
> match <expr> with
> | A(_) | B(_) | C(_) -> foo
> | C(_) | D(_) | E(_) -> bar
>
> Neither does the compiler accept such code, nor does the
> manual mention such construct. Has it been removed from the
> language or am I suffering severe brain damage from too much
> O'Caml coding?
>
> Alex
>
> -------------------
> 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
>
-------------------
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