just that, when you define
type stm =
SEQ of stm * stm
in lay terms you are saying that "stm" may be of some type named
"SEQ" which is composed of an ("stm", "stm") tuple.
--- In ocaml_beginners%40yahoogroups.com">ocaml_beginners
yahoogroups.com, LianYang <yanglian
...> wrote:
>
> Thank both of you!
> 1. Then, could i say, the star "*" here is used to define tuple?
>
> 2. And it's used to represent tree structure, right?
> type stm = SEQ of stm * stm
>
> I'm asking this kind of thing because i'm writing the tiger compiler in
> ocaml.
>
> On 5/29/07, Pablo Polvorin <pablo.polvorin
...> wrote:
> >
> > > like in
> > > # type exp =
> > > CONST of int * int;;
> > > how to write such a type?
> > > 1*1;;
> > also, that type definition actually defines a Variant type so to
> > create a value of type exp, you should use the CONST constructor that
> > you has previusly defined:
> > # let b = CONST(2,3);;
> > val b : expr = CONST (2, 3)
> >
> > 2007/5/29, Jon Harrop <jon
... <jon%40ffconsultancy.com>>:
> >
> > > On Tuesday 29 May 2007 05:24:34 LianYang wrote:
> > > > what is the meaning of "*"? thanks.
> > > >
> > > > type stm =
> > > > SEQ of stm * stm
> > > > means stm followed by stm?
> > >
> > > A product type: "a * b" means the Cartesian product of the sets of
> > values
> > > "a"
> > > and "b".
> > >
> > > For example, if "a = A1 | A2" and "b = B1 | B2" then "a * b"
represents
> > the
> > > set of values containing:
> > >
> > > (A1, B1)
> > > (A1, B2)
> > > (A2, B1)
> > > (A2, B2)
> > >
> > > > like in
> > > > # type exp =
> > > > CONST of int * int;;
> > > > how to write such a type?
> > > > 1*1;;
> > >
> > > If you mean: how do I create a value of the type "int * int",
then you
> > write
> > > a
> > > tuple, in this case a pair of two ints:
> > >
> > > # (1, 2);;
> > > - : int * int = (1, 2)
> > >
> > > --
> > > Dr Jon D Harrop, Flying Frog Consultancy Ltd.
> > > The F#.NET Journal
> > > http://www.ffconsultancy.com/products/fsharp_journal/?e
> > >
> >
> > --
> > Pablo Polvorin
> >
> >
> >
>
>
> [Non-text portions of this message have been removed]
>
.