Created
August 2, 2021 12:25
-
-
Save guz-anton/cd0df2f7e7605b387194f58d0c7a3b3d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fx = (fn, start, ...xn) => { | |
const FF = class { | |
constructor (...rn) { | |
const ww = (...wn) => { return new FF(...rn, ...wn)} | |
ww.valueOf = () => this.valueOf() | |
ww.toString = () => this.toString() | |
this.items = rn | |
return ww | |
} | |
value() {return this.items.reduce(fn, start)} | |
valueOf () {return this.value() - 0} | |
toString () {return this.value() + ''} | |
} | |
return new FF(...xn) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fx = (fn, start, ...xn) => { | |
let value; | |
const fy = (...yn) => { | |
value = [...xn, ...yn].reduce(fn, start); | |
return fy; | |
}; | |
fy.valueOf = () => {return value - 0}; | |
fy.toString = () => {return value + ''}; | |
return fy; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment