Thursday, May 28, 2015

Pre-Requisites

https://en.wikipedia.org/wiki/Higher-order_function

https://en.wikipedia.org/wiki/First-class_function#Higher-order_functions:_passing_functions_as_arguments


https://en.wikipedia.org/wiki/Erlang_(programming_language)#Functional_programming_examples

https://en.wikipedia.org/wiki/Functional_programming

https://en.wikipedia.org/wiki/First-class_function


http://scala-ide.org/download/sdk.html
http://www.scala-lang.org/download/


http://www.cis.upenn.edu/~matuszek/General/JavaSyntax/inner-classes.html

Video: Scala tricks: https://www.youtube.com/watch?v=oW6c_INmzEs


Local inner classes are often used in Java to define callbacks for GUI code. Components can then share an object that implements an event handling interface or extends an abstract adapter class, containing the code to be executed when a given event is triggered.
Anonymous inner classes are also used where the event handling code is only used by one component and therefore does not need a named reference.
This avoids a large monolithic actionPerformed(ActionEvent) method with multiple if-else branches to identify the source of the event. This type of code is often considered messy and the inner class variations are considered to be better in all regards.




First-class functions are a necessity for the functional programming style, in which the use of higher-order functions is a standard practice. A simple example of a higher-ordered function is the map function, which takes, as its arguments, a function and a list, and returns the list formed by applying the function to each member of the list. For a language to support map, it must support passing a function as an argument.



Higher-order functions are closely related to first-class functions in that higher-order functions and first-class functions both allow functions as arguments and results of other functions. The distinction between the two is subtle: "higher-order" describes a mathematical concept of functions that operate on other functions, while "first-class" is a computer science term that describes programming language entities that have no restriction on their use (thus first-class functions can appear anywhere in the program that other first-class entities like numbers can, including as arguments to other functions and as their return values).
Higher-order functions enable partial application or currying, a technique in which a function is applied to its arguments one at a time, with each application returning a new function that accepts the next argument. This allows one to succinctly express, for example, the successor function as the addition operator partially applied to the natural numberone.