Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const reduce_op = (op, def) => {
- let fn = ''
- + 'function () {'
- + ' return Array.from(arguments)'
- + ' .reduce((a, n) => typeof n === "undefined" ? a : (a ' + op + ' n), '+ def +')'
- return eval(fn)
- }
- // every programmer should implement a lisp interpreter once in their life
- 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