13

JavaScript - Dynamic curry function for addition

Comments
  • 4
    I think i win
  • 3
    Nice exercise, but it's way too much work to do this in 99% of cases
  • 3
    (a=>a.bind(0,a))((f,n,s,a)=>a?a[0]?s:f.bind(0,f,0,(s?s:"")+String.fromCharCode(n)):f.bind(0,f,n+1,s))()``()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()``()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()``()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()``()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()``()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()``()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()```'`
  • 4
    @WIPocket When Lisp programmer writes javascript...
  • 1
    @ganjaman aren't operators already curried in OCaml?
  • 1
  • 1
    @WIPocket That's cool, I spent few minutes analysing it and built a parenthesis generator:

    const stringToParenthesis = str => {
    return '(a=>a.bind(0,a))((f,n,s,a)=>a?a[0]?s:f.bind(0,f,0,(s?s:"")+String.fromCharCode(n)):f.bind(0,f,n+1,s))()``'+Array.from(str).map(char => {
    let str = '';
    for(let i=0; i<char.charCodeAt(0); i++) {
    str+='()';
    }
    return str;
    }).join('``')+'```\'`';
    };
  • 1
    inb4 obligatory "Javascript sucks doo doo because it sucks doo doo"
  • 1
    @crisz Cool spagetti!
    I also made one (and figured out it crashes after too many characters when you execute it because of a stack overflow/too much recursion)
  • 0
    what does curry have to do with any of this
  • 1
Add Comment