SlideShare a Scribd company logo
Functional Programming
CSEC SEMINAR
What a seminar (at least mine) isn’t …
 A lecture
 A tutorial
 A
What a seminar (at least mine) is about
 Sharing ‘Aha’ moments
 Building a vibrant community
About Me
 A CEO
 A web application developer
 An expert in Functional programming.
What is FP?
 A programming paradigm
 A coding style
 A mindset
 A hype
 Closures
 Currying
 Higher-Order-Functions
 Side-effects
 Lambda expressions
 Reduce , filter, map
BUZZ WORDS
What FP is not …
 A procedural programming
 All about creating functions and using them
Thinking
Functional
CONCEPTS
Basic FP Concepts
 Functions as a first-class-citizens
 Immutable values over mutable variables
 Currying, partial application of functions
 Laziness, deferred execution
 Avoiding side-effects
 DRY
Thinking Functional
”
“A first-class citizen : an entity which supports
all the operations generally available to other
entities. These operations typically include
being passed as an argument, returned from
a function, and assigned to a variable.
SCOTT, MICHAEL (2006). PROGRAMMING LANGUAGE PRAGMATICS
Demo
Thinking Functional
Side-effects
 a function or expression is said to have a side effect if it modifies some
state or has an observable interaction with calling functions or the
outside world.
 For example, a particular function might modify a global variable or
static variable, modify one of its arguments, raise an exception, write
data to a display or file, read data, or call other side-effecting functions.
 In the presence of side effects, a program's behaviour may depend on
history; that is, the order of evaluation matters. Understanding and
debugging a function with side effects requires knowledge about the
context and its possible histories.
Thinking Functional
Pure vs Impure
 The function always evaluates the same result value given the same argument
value(s). The function result value cannot depend on any hidden information or
state that may change while program execution proceeds or between different
executions of the program, nor can it depend on any external input from I/O
devices.
 Evaluation of the result does not cause any semantically observable side effect or
output, such as mutation of mutable objects or output to I/O devices.
 Pure: sin(x)
 Impure: random()
Code reuse (DRY)
 demo
Don’t iterate MAP, REDUCE, FILTER
Declarative programming
 Declarative programming: A style of building the structure and
elements of computer programs — that expresses the logic of a
computation without describing its control flow.
 E.g: Database query languages (e.g., SQL), regular expressions,
logic programming (e.g., Prolog), functional programming.
Iteration
TheArray<String>[] = { “GoT”,”BrBa”,”Zemen”};
for(int i=0;i<TheArray.size();i++){
System.out.println(“I’ve watched ”+TheArray[i]);
}
Map, reduce , filter, lambda
Demo
Implementing
Languages
Pure
 Haskell
 Curry
Not-pure
 Clojure
 F#
 Scala
 JavaScript
 Java8
Excuses
 This is my very first seminar.
 Internet

More Related Content

PDF
Some basic FP concepts
PPTX
Dev Concepts: Functional Programming
PDF
Functional Programming In PHP I
PPTX
Recursive Function
PPTX
Function & Recursion
PPTX
Function
PPT
User defined functions in C programmig
PPTX
Functions in c
Some basic FP concepts
Dev Concepts: Functional Programming
Functional Programming In PHP I
Recursive Function
Function & Recursion
Function
User defined functions in C programmig
Functions in c

What's hot (20)

PPTX
Functions in C
DOC
Storage classess of C progamming
PPT
user defined function
PPTX
Functions in C
PPTX
structured programming
PDF
Lecture20 user definedfunctions.ppt
PDF
Python functional programming
PPT
Recursion in c
PPTX
Storage Classes and Functions
PDF
(3) cpp procedural programming
PPTX
PHP = PHunctional Programming
PPTX
Function C programming
PDF
Introduction to functional programming
PPTX
Functions in c
PDF
Python Programming - III. Controlling the Flow
PDF
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
PPTX
Function overloading and overriding
PPS
Learn C
PPTX
9. control statement
PDF
Pointers and call by value, reference, address in C
Functions in C
Storage classess of C progamming
user defined function
Functions in C
structured programming
Lecture20 user definedfunctions.ppt
Python functional programming
Recursion in c
Storage Classes and Functions
(3) cpp procedural programming
PHP = PHunctional Programming
Function C programming
Introduction to functional programming
Functions in c
Python Programming - III. Controlling the Flow
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
Function overloading and overriding
Learn C
9. control statement
Pointers and call by value, reference, address in C
Ad

Similar to Functional programming (20)

PPTX
Functional programming in TypeScript
PPT
La5 Basicelement
PPTX
program development and paradigms
PPT
Chapter 5( programming) answer
DOCX
Training 8051Report
PPTX
Procedural programming
PPTX
Functional programming
PPTX
Why functional programming in C# & F#
PPTX
Prgramming paradigms
PDF
C++ notes.pdf
PPTX
Designing function families and bundles with java's behaviors parameterisatio...
PPTX
Lesson5-Algorithms-Flowcharts-DataTypes-Pseudocode.pptx
PPTX
Mvi an architecture for reactive programming
PPTX
PROGRAMMING LANGUAGE AND TYPES
PPT
debugging - system software
DOCX
DOCX
PDF
Definitions of Functional Programming
PPTX
Program understanding: What programmers really want
PDF
Reactive programming with cycle.js
Functional programming in TypeScript
La5 Basicelement
program development and paradigms
Chapter 5( programming) answer
Training 8051Report
Procedural programming
Functional programming
Why functional programming in C# & F#
Prgramming paradigms
C++ notes.pdf
Designing function families and bundles with java's behaviors parameterisatio...
Lesson5-Algorithms-Flowcharts-DataTypes-Pseudocode.pptx
Mvi an architecture for reactive programming
PROGRAMMING LANGUAGE AND TYPES
debugging - system software
Definitions of Functional Programming
Program understanding: What programmers really want
Reactive programming with cycle.js
Ad

Recently uploaded (20)

PDF
KodekX | Application Modernization Development
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Machine learning based COVID-19 study performance prediction
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
Spectroscopy.pptx food analysis technology
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Approach and Philosophy of On baking technology
KodekX | Application Modernization Development
Programs and apps: productivity, graphics, security and other tools
Machine learning based COVID-19 study performance prediction
Advanced methodologies resolving dimensionality complications for autism neur...
Understanding_Digital_Forensics_Presentation.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Spectroscopy.pptx food analysis technology
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Reach Out and Touch Someone: Haptics and Empathic Computing
Network Security Unit 5.pdf for BCA BBA.
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
NewMind AI Weekly Chronicles - August'25 Week I
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Spectral efficient network and resource selection model in 5G networks
The Rise and Fall of 3GPP – Time for a Sabbatical?
Approach and Philosophy of On baking technology

Functional programming

  • 2. What a seminar (at least mine) isn’t …  A lecture  A tutorial  A
  • 3. What a seminar (at least mine) is about  Sharing ‘Aha’ moments  Building a vibrant community
  • 4. About Me  A CEO  A web application developer  An expert in Functional programming.
  • 5. What is FP?  A programming paradigm  A coding style  A mindset  A hype
  • 6.  Closures  Currying  Higher-Order-Functions  Side-effects  Lambda expressions  Reduce , filter, map BUZZ WORDS
  • 7. What FP is not …  A procedural programming  All about creating functions and using them
  • 9. Basic FP Concepts  Functions as a first-class-citizens  Immutable values over mutable variables  Currying, partial application of functions  Laziness, deferred execution  Avoiding side-effects  DRY Thinking Functional
  • 10. ” “A first-class citizen : an entity which supports all the operations generally available to other entities. These operations typically include being passed as an argument, returned from a function, and assigned to a variable. SCOTT, MICHAEL (2006). PROGRAMMING LANGUAGE PRAGMATICS Demo Thinking Functional
  • 11. Side-effects  a function or expression is said to have a side effect if it modifies some state or has an observable interaction with calling functions or the outside world.  For example, a particular function might modify a global variable or static variable, modify one of its arguments, raise an exception, write data to a display or file, read data, or call other side-effecting functions.  In the presence of side effects, a program's behaviour may depend on history; that is, the order of evaluation matters. Understanding and debugging a function with side effects requires knowledge about the context and its possible histories. Thinking Functional
  • 12. Pure vs Impure  The function always evaluates the same result value given the same argument value(s). The function result value cannot depend on any hidden information or state that may change while program execution proceeds or between different executions of the program, nor can it depend on any external input from I/O devices.  Evaluation of the result does not cause any semantically observable side effect or output, such as mutation of mutable objects or output to I/O devices.  Pure: sin(x)  Impure: random()
  • 14. Don’t iterate MAP, REDUCE, FILTER
  • 15. Declarative programming  Declarative programming: A style of building the structure and elements of computer programs — that expresses the logic of a computation without describing its control flow.  E.g: Database query languages (e.g., SQL), regular expressions, logic programming (e.g., Prolog), functional programming.
  • 16. Iteration TheArray<String>[] = { “GoT”,”BrBa”,”Zemen”}; for(int i=0;i<TheArray.size();i++){ System.out.println(“I’ve watched ”+TheArray[i]); }
  • 17. Map, reduce , filter, lambda Demo
  • 19. Languages Pure  Haskell  Curry Not-pure  Clojure  F#  Scala  JavaScript  Java8
  • 20. Excuses  This is my very first seminar.  Internet