package listFW.visitor;



import listFW.*;



/**

 * Sums a list of Numbers, including lists of any sub-types.

 */

public class SumNumList implements IListAlgo<Number,Number,Object> {

    

    public Number emptyCase(IMTList<? extends Number> host, Object ... inp) {

        return 0;

    }

    public Number nonEmptyCase(INEList<? extends Number> host, Object ... inp) {

        return host.getFirst().doubleValue() + host.getRest().execute(this).doubleValue();

    }

}

