13. ListΒΆ
Type of list can be figured as following:
xxx
1 2 3 4 5 6 7 | #include "share/atspre_staload.hats"
implement main0 () = {
val l = list_vt_make_pair (1, 2)
val () = print_list_vt<int> l
val () = list_vt_free<int> l
}
|
$ patscc make_pair.dats -DATS_MEMALLOC_LIBC
$ ./a.out
1, 2
xxx
1 2 3 4 5 6 7 8 9 | #include "share/atspre_staload.hats"
implement main0 () = {
val l1 = list_vt_make_pair (1, 2)
val l2 = list_vt_make_sing 3
val l3 = list_vt_append (l2, l1)
val () = print_list_vt<int> l3
val () = list_vt_free<int> l3
}
|
$ patscc append_list.dats -DATS_MEMALLOC_LIBC
$ ./a.out
3, 1, 2