package kernel.function; import kernel.Cell; import kernel.LanguageEnum; import java.util.List; import java.util.OptionalDouble; public class Average extends Function { public Average(List listCells) { super(listCells); this.names.put(LanguageEnum.FR, "MOYENNE"); this.names.put(LanguageEnum.EN, "AVERAGE"); } public double eval() { OptionalDouble average = this.listCells.stream().mapToDouble(Cell::getValue).average(); return average.isPresent() ? average.getAsDouble() : 0.; } }