#include #include "memsim.h" #include "memsim-decl.h" int main(){ int fcons, temp; fcons = cons(1, cons(2, cons(3, 0))); printf("testing indices:\n%d\n%d\n%d\n", fcons, rest(fcons), rest(rest(fcons))); printf("contents are:\n"); temp = fcons; while(temp != 0){ printf("%d\n", first(temp)); temp = rest(temp); } // printf("First: %d\nSecond: %d\nThird: %d\nLast: %d\n", //first(fcons),first(rest(fcons)),first(rest(rest(fcons))), rest(rest(rest(fcons)))); printf("freeing list...\n"); give_back(fcons); printf("free_list is: %d\n",free_list); printf("repopulating list fully with numbers\n"); fcons = cons(1,cons(2,cons(3,cons(4,0)))); printf("previous give_back and repopulation succeeded without errors\n"); printf("contents are:\n"); temp=fcons; while(temp != 0){ printf("%d\n",first(temp)); temp = rest(temp); } printf("giving back again...\n"); give_back(fcons); printf("Suceeded...creating one more cons...\n"); fcons = cons(255,0); printf("Suceeded, contents is: %d\n", first(fcons)); printf("giving back and ending...\n"); return(0); }