functional programming Flashcards
programming paradigm
is a style of computer programming. different programming languages support tackling problems in different ways.
procedural programming
is supported by languages such as python or pascal, which have a series of instructions that tell the computer what to do with the input in order to solve the problem.
widely used in educational environments, being relatively easy to learn and applicable to w ide variety of problems
structured programming
is a type of procedural programming which uses the programming constructs of sequence, selection, iteration and recursion. it uses modular techniques to split large programs into manageable chunks.
object oriented programming
is supported by languages such as java, python and delphi. OOP was developed to make it possible to abstract details of implementation away from the user, make code reusable and programs easy to maintain. it is to a great extent taking over from procedural memory.
declarative programming
is supported by languages such as SQL, where you write statements that describe the problem to be solved, and the language implementation decides the best way of solving it. SQL is used to query databases.
functional programming
is supported by programming languages such as haskell, as well as python, c# and java. functions not objects or procedures, are used as the fundamental building blocks of a program. statements are written as a series of functions which accept input data as arguments and return an output.
domain
a set from the functions input values are chosen
co-domain
a set from which the functions output values are chosen
arguement
is a value or expression passed to a function
parameter
is a reference declared in function declaration
function application
the process of giving particular inputs to a function
first-class objects
is an object which may:
- appear in expressions
- be assigned to a variable
- be assigned as an argument
- be returned in a functional call
e.g. integers, floating point values, characters and strings. functions are also first-class objects so may themselves be passed as arguments
stateless
in a functional programming language, the value of a variable cannot change. variables are said to be immutable.
no side affects
the only thing a function is calculate something and return a result, and it is said to have no side effects
referential transparency
a consequence of not being able to change the value of an object is that a function that is called twice with the same parameters will always return the same result.
makes it relatively easy for programmers to write correct, bug-free programs
composition of functions
the combination of two functions to produce a new function that performs the two functions in a specified order