Objectives


• Understand Function Specifi cation. • Parameters (and arguments). • Interface Vs Implementation. • Pure functions. • Side - eff ects (impure functions).

Summary


• Algorithms are expressed using statements of a programming language • Subroutines are small sections of code that are used to perform a particular task that can be used repeatedly • A function is a unit of code that is often defined within a greater code structure • A function contains a set of code that works on many kinds of inputs and produces a concrete output • Definitions are distinct syntactic blocks • Parameters are the variables in a function definition and arguments are the values which are passed to a function definition through the function definition. • When you write the type annotations the parentheses are mandatory in the function definition • An interface is a set of action that an object can do • Interface just defines what an object can do, but won’t actually do it • Implementation carries out the instructions defined in the interface • Pure functions are functions which will give exact result when the same arguments are passed • The variables used inside the function may cause side effects though the functions which are not passed with any arguments. In such cases the function is called impure function