Non-decimal radices/Convert: Difference between revisions

Content added Content deleted
(→‎ES6: (updated primitive – replaced recursive until with iterative until))
Line 1,574: Line 1,574:
// until :: (a -> Bool) -> (a -> a) -> a -> a
// until :: (a -> Bool) -> (a -> a) -> a -> a
const until = (p, f, x) => {
const until = (p, f, x) => {
const go = x => p(x) ? x : go(f(x));
let v = x;
return go(x);
while (!p(v)) v = f(v);
return v;
}
}