/* * ListPlusPlus.java * * Created on March 29, 2007, 9:45 PM * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ /** * * @author Jeff */ public class ListPlusPlus extends List{ /** Creates a new instance of ListPlusPlus */ public ListPlusPlus() { } public static List stutter(List k) throws BadIndexException { if (ListPlus.isEmpty(k)) return List.nil(); else { Element a = k.getMember(0); List l = ListPlus.drop(1,k); return ListPlus.cons(a,ListPlus.cons(a, stutter(l))); } } public static List prefix(List k) throws BadIndexException { if (ListPlus.isEmpty(k)) return List.nil(); else { List l = List.nil(); int i =1; while (i=1) { l= ListPlus.cons(ListPlus.drop(i,k),l); i--; } return ListPlus.cons(l,suffix(ListPlus.take(ListPlus.getLength(k)-1,k))); } } }