From: stalkern2 <stalkern2@tin.it>
To: caml-list@inria.fr
Subject: Re: [Caml-list] [Beginner in CAML] Pas avec les listes
Date: Thu, 31 Jan 2002 14:45:23 -0500 [thread overview]
Message-ID: <20020131133959.IQWC4346.fep43-svc.tin.it@there> (raw)
In-Reply-To: <A7615804EC6DD511B90B0004ACE5BE4B5CA2FB@L-RMHS.rd.francetelecom.fr>
Ça ne change rien par rapport au type enregistrement ou au tipe couple.
Le type "list" n'existe pas, soit, c'est un super-type, c'est toujours une
"list de quelque chose", et ses données sont homogènes.
Alors ce qu'il faut ce n'est pas de définir le type "rationnel" à partir d'un
type "liste", mais définir au plus un type "liste de rationnels" à partir du
type "liste de quelque chose".
Ceci parce que les listes servent a gérer des séquences, c'est-à-dire
à ^etre tranchées, non pas à servir de modèle.
Dans le cas des rationnels, un tipe {(int1:int) ; (int2:int) } ou un couple
(int * int) est utilisé d'habitude.
Dans le cas du type enregistrement, tu en tires un vrai rationnel disant
par ex.
type rat = {int1:int;int2:int};;
let vrai_rat = {int1=3;int2=4};;
et tu en récupéres le contenu appelant vrai_rat.int1 et vrai_rat.int2
Dans le cas du couple, tu peux utiliser le type casting
type rat = int * int;;
let (vrai_rat:rat) = (3,4);;
pour obtenir un vrai rationnel e tu as fst(int * int) et snd(int * int) ou
bien des pattern matchings pour récupérer le contenu.
Ciao
Ernesto
PS Je suis un beginner aussi, j'espère avoir bien dit.
Alle ore 06:27, giovedì 31 gennaio 2002, COLLINEAU Franck FTRD/DMI/TAM ha
scritto:
> Greetings,
>
> I would like to create the rational type from the list type.
>
> How can i do ?
>
> Regards,
>
> Franck
-------------------
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
prev parent reply other threads:[~2002-01-31 13:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-01-31 11:27 [Caml-list] [Beginner in CAML] Rational type COLLINEAU Franck FTRD/DMI/TAM
2002-01-31 19:45 ` stalkern2 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20020131133959.IQWC4346.fep43-svc.tin.it@there \
--to=stalkern2@tin.it \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox