Skip to content

Instantly share code, notes, and snippets.

@Lodo4ka
Created September 7, 2019 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lodo4ka/12f71a57f2c3106fc828454a3b0b5221 to your computer and use it in GitHub Desktop.
Save Lodo4ka/12f71a57f2c3106fc828454a3b0b5221 to your computer and use it in GitHub Desktop.
const fn = (f, list) => {
if(list.length === 0) {
return [];
}
const [x, ...xs] = list
return f(x) ? [x, ...fn(f, xs)]: fn(f,xs)
}
const arrEx = [4, 2, 5, 1, 3];
const param = (a) => a === 4
console.log(fn(param, arrEx))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment