English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] removing an item from a list efficiently
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-11-08 (18:00)
From: Brian Hurt <bhurt@s...>
Subject: Re: [Caml-list] removing an item from a list efficiently
On Sat, 8 Nov 2003, Dustin Sallings wrote:

> type 'a link = Nothing | Link of 'a t;;
> type 'a t = {
>      data: 'a;
>      mutable prev: 'a link;
>      mutable next: 'a link;
> };;
> 	But, link and t don't know about each other.  How does one go about 
> doing this kind of thing in ocaml?

Use and:

type 'a link = Nothing | Something of 'a t 
and 'a t = { data: 'a; mutable next: 'a link; mutable prev: 'a link }

The other alternative is to not redefine option:

type 'a t = 
    { data: 'a; mutable next: 'a t option; mutable prev: 'a t option } 


"Usenet is like a herd of performing elephants with diarrhea -- massive,
difficult to redirect, awe-inspiring, entertaining, and a source of
mind-boggling amounts of excrement when you least expect it."
                                - Gene Spafford 

To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners