Skip to content

Instantly share code, notes, and snippets.

@indongyoo
Last active April 3, 2018 12:14
Show Gist options
  • Select an option

  • Save indongyoo/e0b52b997b79bdfaad9aa85d4db1490b to your computer and use it in GitHub Desktop.

Select an option

Save indongyoo/e0b52b997b79bdfaad9aa85d4db1490b to your computer and use it in GitHub Desktop.
const isAny = a => a !== undefined;
const some = map(isAny, find);
log( some(a => a > 2, [1, 2, 4, 5]) );
// true
log( some(a => a < 2, [1, 2, 4, 5]) );
// true
log( some(a => a > 10, [1, 2, 4, 5]) );
// false
const isUndefined = a => a === undefined;
const none = map(isUndefined, find);
log( none(a => a > 2, [1, 2, 4, 5]) );
// false
log( none(a => a < 2, [1, 2, 4, 5]) );
// false
log( none(a => a > 10, [1, 2, 4, 5]) );
// true
const not = a => !a;
const every = (f, coll) => isUndefined(find(map(not, f), coll));
log( every(a => a < 2, [1, 2, 4, 5]) );
// false
log( every(a => a > 10, [1, 2, 4, 5]) );
// false
log( every(a => a > 0, [1, 2, 4, 5]) );
// true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment