Created
November 13, 2017 09:05
-
-
Save ulve/cebe58101f5e1099d018bf09b775df0e to your computer and use it in GitHub Desktop.
Smalles free bucklescript
This file contains hidden or 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
function minfree(xs) { | |
var _a = 0; | |
var _n = List.length(xs); | |
var _xs = xs; | |
while(true) { | |
var xs$1 = _xs; | |
var n = _n; | |
var a = _a; | |
var b = (a + 1 | 0) + (n / 2 | 0) | 0; | |
var match = List.partition((function(b){ | |
return function (x) { | |
return +(x < b); | |
} | |
}(b)), xs$1); | |
var us = match[0]; | |
var m = List.length(us); | |
if (n) { | |
if (m === (b - a | 0)) { | |
_xs = match[1]; | |
_n = n - m | 0; | |
_a = b; | |
continue ; | |
} else { | |
_xs = us; | |
_n = m; | |
continue ; | |
} | |
} else { | |
return a; | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment