DEV Community

Discussion on: A Tale of Two Functions

Collapse
deciduously profile image
Ben Lovy Author

Nice and concise! rxjs looks great, I should give it a look.

Collapse
asparallel profile image
AsParallel

It's definitely nice if you have to do js. Since you're already using F#, elmish is probably the best option overall :) They can also be mixed at runtime.

github.com/elmish/elmish

Thread Thread
deciduously profile image
Ben Lovy Author

All signs keep pointing here. Guess I gotta go :)

Collapse
asparallel profile image
AsParallel

Was thinking, the most concise version of this just exploits the ascii table to eliminate most of the checks. And also probably fails code review:

     reduce(([previous, result], val: string) =>
        previous !== result &&
            (Math.abs(previous.charCodeAt(0) - val.charCodeAt(0))) === 0x20
            ? [result.charAt(result.length - 2), result.slice(0, result.length - 1)]
            : [val, result + val]
        , ['', '']),