@Test public void testZeroArgs() throws Exception { Plus plus = new Plus(); assertEquals(0, plus.execute(rhsFuncContext, Symbols.asList(syms)).asInteger().getValue()); }
@Override public Symbol execute(RhsFunctionContext context, List<Symbol> arguments) throws RhsFunctionException { RhsFunctions.checkAllArgumentsAreNumeric(getName(), arguments); long i = 0; double f = 0; boolean float_found = false; for(Symbol arg : arguments) { IntegerSymbol ic = arg.asInteger(); if(ic != null) { if(float_found) { f += ic.getValue(); } else { i += ic.getValue(); } } else { if(float_found) { f += arg.asDouble().getValue(); } else { float_found = true; f = i + arg.asDouble().getValue(); } } } final SymbolFactory syms = context.getSymbols(); return float_found ? syms.createDouble(f) : syms.createInteger(i); }
Plus extends AbstractRhsFunctionHandler { @Override public Symbol execute(RhsFunctionContext context, List<Symbol> arguments) throws RhsFunctionException { RhsFunctions.checkAllArgumentsAreNumeric(getName(), arguments); long i = 0; double f = 0; boolean float_found = false; for(Symbol arg : arguments) { IntegerSymbol ic = arg.asInteger(); if(ic != null) { if(float_found) { f += ic.getValue(); } else { i += ic.getValue(); } } else { if(float_found) { f += arg.asDouble().getValue(); } else { float_found = true; f = i + arg.asDouble().getValue(); } } } final SymbolFactory syms = context.getSymbols(); return float_found ? syms.createDouble(f) : syms.createInteger(i); } }
Plus extends AbstractRhsFunctionHandler { @Override public Symbol execute(RhsFunctionContext context, List<Symbol> arguments) throws RhsFunctionException { RhsFunctions.checkAllArgumentsAreNumeric(getName(), arguments); long i = 0; double f = 0; boolean float_found = false; for(Symbol arg : arguments) { IntegerSymbol ic = arg.asInteger(); if(ic != null) { if(float_found) { f += ic.getValue(); } else { i += ic.getValue(); } } else { if(float_found) { f += arg.asDouble().getValue(); } else { float_found = true; f = i + arg.asDouble().getValue(); } } } final SymbolFactory syms = context.getSymbols(); return float_found ? syms.createDouble(f) : syms.createInteger(i); } Plus(); }
Plus extends AbstractRhsFunctionHandler { @Override public Symbol execute(RhsFunctionContext context, List<Symbol> arguments) throws RhsFunctionException { RhsFunctions.checkAllArgumentsAreNumeric(getName(), arguments); long i = 0; double f = 0; boolean float_found = false; for(Symbol arg : arguments) { IntegerSymbol ic = arg.asInteger(); if(ic != null) { if(float_found) { f += ic.getValue(); } else { i += ic.getValue(); } } else { if(float_found) { f += arg.asDouble().getValue(); } else { float_found = true; f = i + arg.asDouble().getValue(); } } } final SymbolFactory syms = context.getSymbols(); return float_found ? syms.createDouble(f) : syms.createInteger(i); } Plus(); @Override Symbol execute(RhsFunctionContext context, List<Symbol> arguments); }
Plus extends AbstractRhsFunctionHandler { @Override public Symbol execute(RhsFunctionContext context, List<Symbol> arguments) throws RhsFunctionException { RhsFunctions.checkAllArgumentsAreNumeric(getName(), arguments); long i = 0; double f = 0; boolean float_found = false; for(Symbol arg : arguments) { IntegerSymbol ic = arg.asInteger(); if(ic != null) { if(float_found) { f += ic.getValue(); } else { i += ic.getValue(); } } else { if(float_found) { f += arg.asDouble().getValue(); } else { float_found = true; f = i + arg.asDouble().getValue(); } } } final SymbolFactory syms = context.getSymbols(); return float_found ? syms.createDouble(f) : syms.createInteger(i); } Plus(); @Override Symbol execute(RhsFunctionContext context, List<Symbol> arguments);  }