Topological sort: Difference between revisions
→{{header|ATS}}
Line 512:
staload UN = "prelude/SATS/unsafe.sats"
(* Macros for list construction. *)
#define NIL list_nil ()
#define :: list_cons
(*------------------------------------------------------------------*)
(* A shorthand for list reversal. This could also have been written as
▲ better than a macro. *)
fn {a : t@ype}
rev {n : int}
Line 525 ⟶ 527:
that result to a "regular" list. *)
list_vt2t (list_reverse<a> lst)
(*------------------------------------------------------------------*)
(* Some shorthands for string operations. These are written as
macros. *)
macdef substr (s, i, n) =
(* string_make_substring returns a linear strnptr, but we want a
"regular" string. *)
macdef copystr (s) =
(* string0 copy returns a linear strptr, but we want a "regular"
string. *)
strptr2string (string0_copy (,(s)))
(*------------------------------------------------------------------*)
Line 676 ⟶ 692:
val j = skip_ident (text, n, i)
val () = $effmask_exn assertloc (i < j)
val nodename = substr (text, i, j - i)
▲ (string_make_substring (text, i, j - i))
in
loop (nodename :: row, j)
Line 742 ⟶ 756:
c := $extfcall (int, "getchar")
end;
end
Line 1,127 ⟶ 1,141:
nodenames_array[i]
(* A shorthand
macdef map (lst) =
list_vt2t (list_map<nodenum n><String1> ,(lst))
|