caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] [Beginner in CAML] Rational type
@ 2002-01-31 11:27 COLLINEAU Franck FTRD/DMI/TAM
  2002-01-31 19:45 ` [Caml-list] [Beginner in CAML] Pas avec les listes stalkern2
  0 siblings, 1 reply; 2+ messages in thread
From: COLLINEAU Franck FTRD/DMI/TAM @ 2002-01-31 11:27 UTC (permalink / raw)
  To: 'caml-list@inria.fr'


[-- Attachment #1.1: Type: text/plain, Size: 110 bytes --]

Greetings,

I would like to create the rational type from the list type.

How can i do ?

Regards,

Franck




[-- Attachment #1.2: Type: text/html, Size: 637 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] [Beginner in CAML] Pas avec les listes
  2002-01-31 11:27 [Caml-list] [Beginner in CAML] Rational type COLLINEAU Franck FTRD/DMI/TAM
@ 2002-01-31 19:45 ` stalkern2
  0 siblings, 0 replies; 2+ messages in thread
From: stalkern2 @ 2002-01-31 19:45 UTC (permalink / raw)
  To: caml-list

Ç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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-01-31 13:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-31 11:27 [Caml-list] [Beginner in CAML] Rational type COLLINEAU Franck FTRD/DMI/TAM
2002-01-31 19:45 ` [Caml-list] [Beginner in CAML] Pas avec les listes stalkern2

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).