|
List Info
Thread: "ocaml_beginners"::[] "*" in type
|
|
| "ocaml_beginners"::[]
"*" in type |
  United States |
2007-05-28 23:24:34 |
|
what is the meaning of "*"? thanks.
type stm =
SEQ of stm * stm
means stm followed by stm?
like in
# type exp =
CONST of int * int;;
how to write such a type?
1*1;;
?
[Non-text portions of this message have been removed]
__._,_.___
.
__,_._,___
|
| Re: "ocaml_beginners"::[]
"*" in type |
  United Kingdom |
2007-05-29 00:07:05 |
|
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
__._,_.___
.
__,_._,___
|
| Re: "ocaml_beginners"::[]
"*" in type |
  United States |
2007-05-29 02:01:25 |
|
> 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%40ffconsultancy.com">jon ffconsultancy.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
__._,_.___
.
__,_._,___
|
| Re: "ocaml_beginners"::[]
"*" in type |
  United States |
2007-05-29 04:41:21 |
|
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%40gmail.com">pablo.polvorin gmail.com> 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%40ffconsultancy.com">jon ffconsultancy.com <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]
__._,_.___
.
__,_._,___
|
[1-4]
|
|