List Info

Thread: "ocaml_beginners"::[] Re: "*" in type




"ocaml_beginners"::[] Re: "*" in type
country flaguser name
United States
2007-05-29 18:06:02


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_beginnersyahoogroups.com, LianYang <yanglian...> wrote:
&gt;
> Thank both of you!
>; 1. Then, could i say, the star "*&quot; here is used to define tuple?
&gt;
> 2. And it's used to represent tree structure, right?
&gt; type stm = SEQ of stm * stm
>
> I'm asking this kind of thing because i'm writing the tiger compiler in
> ocaml.
&gt;

> On 5/29/07, Pablo Polvorin <pablo.polvorin...> wrote:
&gt; >
>; > > like in
> > > # type exp =
> > > CONST of int * int;;
&gt; > > how to write such a type?
&gt; > > 1*1;;
&gt; > 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:
&gt; > > > what is the meaning of "*&quot;? 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
&gt; > > "a&quot;
> > > and "b&quot;.
> > >
>; > > 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;;
&gt; > > > how to write such a type?
&gt; > > > 1*1;;
&gt; > >
>; > > If you mean: how do I create a value of the type "int * int",
then you
> > write
&gt; > > a
> > > tuple, in this case a pair of two ints:
&gt; > >
>; > > # (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
&gt; > >
>; >
>; > --
> > Pablo Polvorin
> >
>; >
> >
>;
>
> [Non-text portions of this message have been removed]
>

__._,_.___
.

__,_._,___
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )