This question is from Douglas Crockford. He askes the students to write a function that takes a binary function, and makes it callable with two invocations. Like : applyf(mul)(5)(6) == 30. Do you know how to write this function?
From Douglas Crockford, one solution is :
But this function is a bit tedious. Not very flexvible. One other method we can use is :
Later we just need to check the number of args, if it's 3, then we execute the binary function and return the result. Otherwise, we continue to read arguments and execute the applyf function.
Sorry! You need to login first to post answer.
Yesterday I was using a DVD to install an OS. In the meantime, the command line prompt asks to Press any key to boot. I searched the whole keyboard and didn"t find the any key. I was so frustrated that I hit the keyboard heavily. You know what? The reboot started and installation completed. What hap
- ► What weekend projects have you created?
- ► What's your opinion about Alibaba mooncake incident?
- ► Should a CTO write code?
- ► What does it feel to have a programmer dad or mom?
- ► Should we be worried about the win of AlphaGo?
- ► Why doesn't IBM file legal brief in support of Apple?
- ► What are the big Internet events in 2015?
- ► Will Elon Musk get into drone business?
- ► What does your work cubicle look like?
- ► What are you most afraid of as a programmer?