2. Table Of Contents
Meaning of paradigm 3
What is functional paradigm 4
Functional paradigm 5
Rules of Functional Paradigm 6
Principles of Functional Paradigm 7
Pure and impure functions 8
Examples of Functional paradigm 9
3. Paradigms
Paradigm can also be termed as method to solve some problem or do some task. Programming
paradigm is an approach to solve problem using some programming language. They are a lot of
programming paradigm but this group will focus on Functional Paradigms.
4. What is Functional Paradigms?
The key principle of this paradigms is the execution of series of mathematical functions.Writing
software should adhere to the crucial principle of making the complicated components of our system
explicit, which functional programming is a paradigm that requires us to do. In functional
paradigm,functions are first-class citizens,Furthermore functions operate without unforeseen
consequences, just like they would when analyzing mathematical functions.
https://youtu.be/dAPL7MQGjyM?si=FXrdmKcseyki7l6M
5. Functional Paradigm
The goal of the functional programming paradigm is to write scalable, dependable code.
Functional programming makes your code more readable and predictable by breaking it up into
separate, autonomous functions that support immutability, pure functions, and function
compositions.
6. Rules of Functional Paradigm
Two main things to know about function paradigm is that:
Data is immutable: To change data,using an array, a new array should be created.
Functions are stateless: Functions always gives the same return value for each arguments.
7. Principles of Functional Paradigm
I. Pure Functions: Referential Transparency and immutability
I. Immutable Variables:Functions are not allowed to change
I. First Class Functions and Higher-Order Functions: Functions stored in variables
I. Function Recursion: The act of using a function to call itself in that same function
8. Pure vs Impure functions
Pure functions take some input and give a fixed output. Also, they cause no side effects in the outside world.
Const add = (a, b) => a + b;
Here, add is a pure function. This is because, for a fixed value of a and b, the output will always be the same.
const SECRET = 42;
const getId = (a) => SECRET * a;
getId is not a pure function. The reason being that it uses the global variable SECRET for computing the output. If SECRET were to change, the getId function
will return a different value for the same input. Thus, it is not a pure function.
let id_count = 0;
const getId = () => ++id_count;
9. Examples of Functional Paradigm
Java Script: developed by Brendan Erich
Scala: Developed by Martin Odersky
Erlang : Developed by Joe Armstrong,Robert Virding
Clojure: Developed by Rich Hickey
ML: Developed by Robin Milner