-- file name chkdbl.adb, a program to test the list and list.dbl -- packages, however, since gnat won't allow me to -- instantiate the io package for doubly-linked lists , -- intlistn.dbl.io, I simply used the Put for singly-linked lists, -- defined in intlistn.io, -- for both (there's no difference), and never needed the doubly-linked -- list io package. with intlistn.io, intlistn.dbl,text_io,int_io; use text_io,int_io, intlistn, intlistn.io; procedure chkdbl is package intdbl renames intlistn.dbl; procedure print_msg_list( S: String; L: Pointer) is begin New_Line; Put(S); Put(L); end print_msg_list; L, DL, OneToGo, OneBefore : pointer; begin L := cons(1, cons(2, cons(3, Empty))); print_msg_list("List L starts out with: ", L); DL := intdbl.cons(2, intdbl.cons(4, intdbl.cons(6, Empty))); print_msg_list("List DL starts out with: ", DL); insert(12, L, L); print_msg_list("should be 1 12 2 3, is: ", L); intdbl.insert(24, DL, DL); print_msg_list("should be 2 24 4 6, is: ", DL); put_line("IsEmpty(L)?"); if IsEmpty(L) then put_line("yes"); else put_line("no"); end if; put_line("IsEmpty(DL)?"); if IsEmpty(DL) then put_line("yes"); else put_line("no"); end if; OneBefore := rest(L); OneToGo := rest(OneBefore); delete(OneToGo, OneBefore, L); print_msg_list("should be 1 12 3, is: ", L); OneToGo := rest(rest(DL)); OneBefore := intdbl.prev(OneToGo); intdbl.delete(OneToGo, OneBefore, DL); print_msg_list("should be 2 24 6, is: ", DL); setFirst(L, 17); print_msg_list("should be 17 12 3, is: ", L); setRest(DL, L); print_msg_list("should be 2 17 12 3, is: ", DL); end chkdbl;