Singly-linked list/Element definition: Difference between revisions

Content added Content deleted
Line 309: Line 309:
=={{header|ATS}}==
=={{header|ATS}}==


<lang ATS>(* The Rosetta Code garbage-collected list type can contain
<lang ATS>(* The Rosetta Code garbage-collected list type can contain any
any t@ype. (The ‘@’ means it doesn’t have to be the size
t@ype. (The ‘@’ means it doesn’t have to be the size of a
of a pointer. You can read {0 <= n} as ‘for all
pointer. You can read {0 <= n} as ‘for all non-negative n’. *)
non-negative n’. *)
datatype rclist_t (t : t@ype+, n : int) =
datatype rclist_t (t : t@ype+, n : int) =
| rclist_t_nil (t, 0)
| rclist_t_nil (t, 0)
| {0 <= n} rclist_t_cons (t, n + 1) of rclist_t (t, n)
| {0 <= n} rclist_t_cons (t, n + 1) of rclist_t (t, n)


(* The Rosetta Code linear list type can contain any vt@ype
(* The Rosetta Code linear list type can contain any vt@ype and so is
and so is more general. *)
more general. *)
dataviewtype rclist_vt (vt : vt@ype+, n : int) =
dataviewtype rclist_vt (vt : vt@ype+, n : int) =
| rclist_vt_nil (vt, 0)
| rclist_vt_nil (vt, 0)