I'm new to functional programming and I'm playing around with the ideas of currying and partial implementation in javascript to wrap my head around them. At the moment I'm trying to workout how I can pass a filter function. Below is a line I saw in a tutorial
var seperate = arr => key => val => arr.filter(obj => obj[key] === val);
say I want to make the filter function a curried parameter so I can create partial implementations with different filter functions applied, such as a var isHuman or var isLessThan50 etc.
Maybe I might want to pass as one argument for the partial implementation the dataset its working on so var filterMembers(membershipData); then I would want to make different filtered implementations var femaleMembers = filterMembers(isFemaleFilter); which would be an array.filter() function.
How would one achieve this?
edit:
I wasn't very clear in my qeustion, apologies. I would like for the array and the filter to be variable. I want to compose seperate functions from the partial implementations.
so I might create a partial implementation that works on the membership array or another that works on census data or something. Then I would like to compose functions from those partial implementations passing different filter functions to the partial implentations that work on the different data sets.
I'm afraid I don't know how to write working code that demonstrates my question.
arr? Running code and a small explanation is better than a long paragraphconst filterMembers = pred => members => members.filter(pred)in whichpredis a function ofany -> boolean?