/* Main{{ public static void p(String s){ System.out.print(s); } public static void main(String args[]) throws Exception { Start start = Start.parse(System.in); // some sample functionality p(start.display() + "\n"); p(start.print() + "\n"); p(start.toStr() + "\n"); System.out.println(start.equals(start)); Map statistics = start.countWords(); p(statistics.toString() + "\n"); p(new Traversal(new Print()).traverse(statistics).toString() + "\n"); p(statistics.keys().toString() + "\n"); for (Word w : statistics.keys()) { p(w.toStr() + "\n"); } // p(statistics.display() + "\n"); } }} */ Start{{ static class WordComp implements java.util.Comparator{ public int compare(Word a, Word b){ return a.id.compareTo(b.id); } } public Map countWords(){ Map in = TUCombiner.traverse(this,new TUCombiner>(){ Map empty = Map.create(new WordComp()); public Map combine(){ return empty; } public Map fold(Map a, Map b){ return a.merge(b, new Map.Merge(){ public Integer merge(Integer i, Integer j){ return i+j; } }); } Map combine(Word n){ return empty.put(n,1); } }); return in; } }}