private static object Subtotal(List <Expression> p) { var fId = (int)(Double)p[0]; var tally = new Tally(p.Skip(1)); switch (fId) { case 1: return(tally.Average()); case 2: return(tally.Count()); case 3: return(tally.CountA()); case 4: return(tally.Max()); case 5: return(tally.Min()); case 6: return(tally.Product()); case 7: return(tally.Std()); case 8: return(tally.StdP()); case 9: return(tally.Sum()); case 10: return(tally.Var()); case 11: return(tally.VarP()); default: throw new ArgumentException("Function not supported."); } }