(updated ) by

Currying Order?

2 rules of functional programming is 1 parameter and each function must return something. Using this, currying helps to bridge the gap allowing multiple parameters.

const add = x => y => x + y
add(1)(2)

So what order should be used?

const find = people => person => people.filter(p => p === person)

or

const find = person => people => people.filter(p => p === person)
find(people)(person)
find(person)(people)

Now if we start to use them we get some curry properties.

const findPerson = find(people)

findPerson(person)
const findPerson = find(person)

findPerson(people)

That’s where I am at now. What is a better option?

Follow-up

With currying, it’s important that the parameters of functions start with options and end with the main operand.

So in our person/people example we would have people be the start, as those are the options.

const findPerson = find(people)
const foundPerson = findPerson(person)
const multiplyVector = size => vector => vector * size

const multiplyVectorBy10 = multiplyVector(10)
multiplyVectorBy10(.8)
const setup = () => {
	const state = {}
	
	const loop = state => () => {

		requestAnimationFrame(loop(state))
	}

	requestAnimationFrame(loop(state))
}

const run = setup({ width: 1024, height: 768 })

run()