Guest User

Untitled

a guest
Jan 22nd, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. const reduce_op = (op, def) => {
  2. let fn = ''
  3. + 'function () {'
  4. + ' return Array.from(arguments)'
  5. + ' .reduce((a, n) => typeof n === "undefined" ? a : (a ' + op + ' n), '+ def +')'
  6. return eval(fn)
  7. }
  8. // every programmer should implement a lisp interpreter once in their life
  9. const fns = '+,0:-,0:*,1:/,1'.split(':').map(p => p.split(',')).map(reduce_op.apply.bind(null))
Add Comment
Please, Sign In to add comment