package examples; /* * Prints the sum of the lengths of its command line arguments. */ import fun.*; import util.*; import java.util.*; public class demo { static Fun length = new MemberFun("length"); static Fun2 add = new Fun2 () { public Integer apply (Integer x, Integer y) { return new Integer(x.intValue()+y.intValue()); } }; static Fun,Integer> sum = FoldR.foldr(add, new Integer(0)); public static void main (String[] args) { System.out.println( sum.apply(length.map(ArrayUtil.iterator(args)))); } }