import java.io.PrintWriter; import java.io.BufferedReader; import java.io.InputStreamReader; /** * Some experiments to better understand Scheme Lists */ public class TestConsList { public static void main(String[] args) throws EmptyListException { // Prepare input and screenput. BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in)); PrintWriter screen = new PrintWriter(System.out, true); // Create a list and print it out. SchemeList lst = new NullList(); screen.println(lst); for (int i = 9; i > 0; i--) { lst = lst.addToFront(new Integer(i)); screen.println(lst); } // Strange test: What happens if we add a list to its own front? lst = lst.addToFront(lst); screen.println(lst); // Repeatedly drop elements from the list. while (!lst.isEmpty()) { lst = lst.cdr(); screen.println(lst); } // That's it, we're done. System.exit(0); } // main(String[]) } // class TestConsList