Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

this code is so smart, maybe because it is Python after all

    from operator import add
    expr = "28+32+++32++39"
    print reduce(add, map(int, filter(bool, expr.split("+"))))
but in JavaScript it looks much more readable:

  "28+32+++32++39".split(/([\+]+)/g).reduce((r,v) => r+v, 0);


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: