Wednesday, August 20, 2014

Mapping Out Lambda Land: An Introduction to Functional Programming

0 comments
What is functional programming? The most succinct answer is...programming with functions! However, using your favorite programming language's 'function' keyword does not mean you are doing functional programming. The functions I am talking about are functions in the mathematical sense, that is, functions that simply map inputs to outputs.

Let's take addition (+) as an example. You might just think of it as a symbol from high school math, but it also happens to be a function that takes two arguments and returns their sum. What is great about addition, and other mathematical functions like it, is that we can count on it to do only that and to do it consistently.

The addition function will only use the inputs you give it to calculate its result. The function's sole mission is to calculate that return value; it will never mess with program state or do anything else observable -- that is, it will not have any side effects. If you give it the same two arguments, it will always return the same result. We call functions like this pure functions.

Read more here

Leave a Reply

 
All Tech News IN © 2011 DheTemplate.com & Main Blogger .