Sunday, January 20, 2008

Programming Terms

While learning scala I needed to know some terms to understand what is going on. So here is a list of terms I needed to understand with an example of what they are in the languages I understand and a link to the definition.

First class object: In java this is an object
wikipedia link

First class functions: In ruby this a a block/proc. First class Functions can be created at runtime stored in a variable and passed into other methods.
wikipedia link

Higher order function: In ruby this is a function that take a block.
wikipedia link

Currying: transforming a function that takes multiple arguments into a function that takes 1 arguement. This can be done by exploiting the fact that a function can be returned by a function.
wikipedia link

Partial Application: Passing less than the full argument list for the function.

map: List[A] => (A => B) : List[B]. Apply a function over a list and return the resulting list

flatMap: List[A] => (A => List[B]) : List[B] . Apply the function A => List[B]
on each element in List[A] and concatenate the results and return the concatenated results.

foldLeft: List => B => ((B, A) => b) : B . Iterate over the list from left to right starting with the value B, accumulate on B and return B. This is the same as the ruby inject method

FoldRight
List => B => ((A, B) => b) : B. same as foldLeft but iterates from right to left.

Associativity: Means that without changing the sequence of the operands, the order of calculation does not effect the result. i.e. (1 + 2) + 5 = 8 = 1 + (2 + 5)
wikipedia link
Commutativity: Changing the sequence of the operands does not effect the result i.e 1+ 2 + 5 = 8 = 5 + 2 + 1
wikipedia link


covariance: to be filled in

contravariance: to be filled in

functor: to be filled in

monad: to be filled in

No comments: