From: John Prevost <prevost@maya.com>
To: Steve Stevenson <steve@cs.clemson.edu>
Cc: caml-list@inria.fr
Subject: Re: Imperative list operations
Date: 15 Sep 1999 09:33:33 -0400 [thread overview]
Message-ID: <m3iu5cb8pe.fsf@isil.maya.com> (raw)
In-Reply-To: Steve Stevenson's message of "Tue, 14 Sep 1999 15:36:18 -0400 (EDT)"
Steve Stevenson <steve@cs.clemson.edu> writes:
> I need a double-ended queue implementation. {...imperative...}
> I've tried all the naïve type declarations --- all of which
> don't seem to work. I've tried the age old tricks. What am I not
> understanding? or doing right? I'm not fussy: tuples, records or
> objects are fine.
It'd help to know what you've tried. The following work for me:
type 'a dlist_node =
| Nil
| Node of 'a dlist_node ref * 'a * 'a dlist_node ref
Or better:
type 'a dlist_node =
{ mutable dlist_prev : 'a dlist_node option;
dlist_val : 'a;
mutable dlist_next : 'a dlist_node option }
Note that in the first case, you need to use value constructors, since:
type 'a dlist_node = 'a dlist_node option ref * 'a * 'a dlist_node option ref
is recursive, and O'Caml doesn't allow type aliases (as opposed to
union types or record types, which "create" new types) to be
recursive.
John.
next prev parent reply other threads:[~1999-09-17 11:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-09-14 19:36 Steve Stevenson
1999-09-15 12:35 ` Jerome Vouillon
1999-09-15 13:09 ` Steve Stevenson
1999-09-15 13:33 ` John Prevost [this message]
1999-09-15 14:35 ` Stefan Monnier
1999-09-17 12:45 ` Markus Mottl
1999-09-16 14:06 ` Christophe Raffalli
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=m3iu5cb8pe.fsf@isil.maya.com \
--to=prevost@maya.com \
--cc=caml-list@inria.fr \
--cc=steve@cs.clemson.edu \
/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