Guest User

Untitled

a guest
May 22nd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. https://localhost:8000/abc/solr?sort=div(popularity,price),bf="recip(rord(price),1,1000,1000)^0.3"
  2.  
  3. import java.util.function.Function;
  4. import javax.script.*;
  5.  
  6. public class TestFunction {
  7. public static void main(String[] args) throws Exception {
  8. ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
  9. @SuppressWarnings("unchecked")
  10. Function<Object,Object> f = (Function<Object,Object>)engine.eval(
  11. String.format("new java.util.function.Function(%s)", args[0]));
  12. for (int i = 1; i < args.length; i++) {
  13. System.out.println(f.apply(args[i]));
  14. }
  15. }
  16. }
  17.  
  18. java TestFunction 'function(x) 3 * x + 1' 17 23 47
  19.  
  20. 52.0
  21. 70.0
  22. 142.0
Add Comment
Please, Sign In to add comment