Functional Programming in JavaScript by Unknown
Author:Unknown
Language: eng
Format: epub, pdf
Publisher: Packt Publishing
First we need to make the curried and partial-applied functions, then we can compose them to our other composed functions.
var lighterColors = lighterColor .compose(nums2hex.curry()); var darkerRed = darkerColor .compose(nums2hex.partialApply(255)); Var lighterRgb2hex = lighterColor .compose(nums2hex.partialApply()); console.log( lighterColors(123, 0, 22) ); // Returns: 8cff11 console.log( darkerRed(123, 0) ); // Returns: ee6a00 console.log( lighterRgb2hex(123,200,100) ); // Returns: 8cd975
There we have it! The functions read really well and make a lot of sense. We were forced to begin with little functions that just did one thing. Then we were able to put together functions with more utility.
Let's look at one last example. Here's a function that lightens an RBG value by a variable amount. Then we can use composition to create new functions from it.
// lighterColorNumSteps :: string -> num -> string function lighterColorNumSteps(color, n) { for (var i = 0; i < n; i++) { color = lighterColor(color); } return color; } // now we can create functions like this: var lighterRedNumSteps = lighterColorNumSteps.curry().compose(reds)(0,0); // and use them like this: console.log( lighterRedNumSteps(5) ); // Return: 'ff5555' console.log( lighterRedNumSteps(2) ); // Return: 'ff2222'
Download
Functional Programming in JavaScript by Unknown.pdf
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(6250)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(5957)
Kotlin in Action by Dmitry Jemerov(4638)
React Native - Building Mobile Apps with JavaScript by Novick Vladimir(2340)
Learning Angular - Second Edition by Christoffer Noring(2168)
Pride and Prejudice by Jane Austen(2097)
Mobile Forensics Cookbook by Igor Mikhaylov(1814)
Computers For Seniors For Dummies by Nancy C. Muir(1769)
Bulletproof Android: Practical Advice for Building Secure Apps (Developer's Library) by Godfrey Nolan(1671)
Building Android UIs with Custom Views by Raimon Ràfols Montané(1621)
Android Development with Kotlin by Marcin Moskala & Igor Wojda(1616)
Building Progressive Web Apps: Bringing the Power of Native to the Browser by Ater Tal(1534)
1936941139 (N) by Bob Rosenthal(1503)
Android App Development by Franceschi Hervé J.;(1497)
Ember.js in Action by Joachim Haagen Skeie(1469)
Hands-On Internet of Things with MQTT by Tim Pulver(1417)
Hands-On Design Patterns with React Native by Mateusz Grzesiukiewicz(1407)
Practical Industrial Internet of Things Security by Sravani Bhattacharjee(1317)
Voice User Interface Projects by Henry Lee(1270)