Created
January 23, 2021 21:47
-
-
Save AndrewRayCode/44fd5cb1868266db33225566ca48d229 to your computer and use it in GitHub Desktop.
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
const foldrLazy = (fn, initialValue, [element, ...rest]) => { | |
if (element === undefined) { | |
return initialValue; | |
} | |
const exists = () => foldrShortCircuit(fn, initialValue, rest); | |
return fn(element, exists); | |
}; | |
const someLazy = (fn, arr) => | |
foldrLazy( | |
(value, accumulated) => fn(value) || accumulated(), | |
false, | |
arr | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment