Last active
September 26, 2020 00:30
-
-
Save forrest-akin/56c88e4f82d36c92e37dd251ccc1718b 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 largestNumber = | |
xs => | |
headIsZero( | |
mapInPlace( toString , xs ) | |
.sort( byBestOrderForLargestNumber ) ) | |
? '0' | |
: xs.join( '' ) | |
const byBestOrderForLargestNumber = | |
( x , y ) => x + y < y + x || -1 | |
const mapInPlace = | |
( f , xs ) => | |
( xs.forEach( ( x , i ) => xs[ i ] = f( x ) ) | |
, xs ) | |
const toString = | |
x => x.toString() | |
const headIsZero = | |
( [ x ] ) => x === '0' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment