SlideShare a Scribd company logo
Functional Programming
Paul Vorobyev and Heman Gandhi
What is a programming paradigm?
A way of approaching code, data, and design.
Imperative is thinking of code as blocks that run from top to bottom.
Data is manipulated by storing and altering values.
Object oriented is thinking of code as an interaction between objects
Objects have behavior and data
Event-driven
The code responds to events and data changes as events happen
The Functional Paradigm
Code is a series of functions. Invocations of
functions are the key operation.
Functions are data types as well, so they can
be accepted as parameters and returned
from other functions (there will be
examples).
Data is always immutable - nothing can be
changed, merely copied.
Why?
Easy to debug.
Elegant.
Concurrent.
Some History on Paradigms
Mathematicians tried to denote everything they could compute and people came
up with their own systems.
Turing came up with the universal Turing machine.
Church helped develop lambda calculus.
Curry helped with combinatory logic.
The universal Turing machine happens to be the easiest to implement with
current hardware.
Lambda Calculus
This is the mathematical foundation of functional programming.
The entirety is two things:
Calling functions (with 1 argument)
Defining functions (with 1 argument)
This is Turing complete.
𝜆x.x // This is the identity function
𝜆x.𝜆y.(y x) //Call the function “y” on some variable “x”.
Alonzo Church
Developed lambda calculus in the 1930s.
Turing and Church proved that a Turing machine and lambda calculus are
equivalent.
The famous “Church-Turing thesis”
Numbers in lambda calculus are “Church numerals”.
𝜆f.𝜆x.x = 0 (and false)
𝜆n.𝜆f.𝜆x.((n f) x) = succ n = n + 1
Haskell Curry
Made Combinatory Logic (similar to lambda calculus).
Has Haskell named after him.
Currying is also named after him (but he didn’t make it). Currying lets you make
n-argument functions from 1-argument functions.
𝜆f.𝜆x.x = 𝜆f x.x //This is well-defined by Currying.
The outer lambdas return a function and the last one returns a value.
((𝜆n m.(n + m)) 4 5) = ((𝜆n.𝜆m.(n + m) 4) 5) = (𝜆m.(4 + m) 5) = 4 + 5 = 9
Examples: Into the Clojure
The syntax of this language is very simple (non-existent).
(<thing being called> <val1> … <val n>)
This is a mean: “(/ (+ x y) 2)”
This is the quadratic formula: (the colorful parens are called rainbow parens)
(/ (+ (* -1 b) (Math/sqrt (- (* b b) (* 4 a c)))) (* 2 a))
This is a simple checker for evenness:
(if (= 0 (mod x 2)) true false) http://www.tryclj.com/
RECURSION!!!!!
Higher order
Closures
Doin’ it live!
Newton’s method solver given an error bound, a function and a function that is
its derivative.
Make it return a function that accepts a starting point.
Google Searches
Languages
Haskell
Scheme
F#
Common Lisp
OCamL
Clojure
Other languages also have good support:
C#, C++, Java
Concepts
Streams (or generators, iterators)
Variable capture
Monads
Functors

More Related Content

What's hot (20)

PDF
Clojure
Rohit Vaidya
 
ODP
Functional Programming for the Rest of Us in Javascript
sathish316
 
PPTX
Lecture 1 and 2
SaheedTundeZubairSTA
 
DOCX
Best,worst,average case .17581556 045
university of Gujrat, pakistan
 
PDF
Algorithms Lecture 6: Searching Algorithms
Mohamed Loey
 
PPT
Algorithm designing using divide and conquer algorithms
SiddhantShelake
 
PPTX
Big O Notation
Marcello Missiroli
 
PPT
Data Structures - Searching & sorting
Kaushal Shah
 
PPT
Data Structure and Algorithms
ManishPrajapati78
 
PPSX
Lecture 3 data structures & algorithms - sorting techniques - http://techiem...
Dharmendra Prasad
 
DOC
Algorithms Question bank
Shivalik college of engineering
 
PPTX
Data structures and algorithms
Hoang Nguyen
 
PPT
Algorithms with-java-advanced-1.0
BG Java EE Course
 
PDF
binary search
Abdelrahman Saleh
 
PPTX
Big o notation
hamza mushtaq
 
PDF
Sorting Algorithms
Mohammed Hussein
 
PDF
Data structures (introduction)
Arvind Devaraj
 
PPT
Sorting Algorithms
multimedia9
 
PPT
Big oh Representation Used in Time complexities
LAKSHMITHARUN PONNAM
 
PPT
Sorting Seminar Presentation by Ashin Guha Majumder
Ashin Guha Majumder
 
Clojure
Rohit Vaidya
 
Functional Programming for the Rest of Us in Javascript
sathish316
 
Lecture 1 and 2
SaheedTundeZubairSTA
 
Best,worst,average case .17581556 045
university of Gujrat, pakistan
 
Algorithms Lecture 6: Searching Algorithms
Mohamed Loey
 
Algorithm designing using divide and conquer algorithms
SiddhantShelake
 
Big O Notation
Marcello Missiroli
 
Data Structures - Searching & sorting
Kaushal Shah
 
Data Structure and Algorithms
ManishPrajapati78
 
Lecture 3 data structures & algorithms - sorting techniques - http://techiem...
Dharmendra Prasad
 
Algorithms Question bank
Shivalik college of engineering
 
Data structures and algorithms
Hoang Nguyen
 
Algorithms with-java-advanced-1.0
BG Java EE Course
 
binary search
Abdelrahman Saleh
 
Big o notation
hamza mushtaq
 
Sorting Algorithms
Mohammed Hussein
 
Data structures (introduction)
Arvind Devaraj
 
Sorting Algorithms
multimedia9
 
Big oh Representation Used in Time complexities
LAKSHMITHARUN PONNAM
 
Sorting Seminar Presentation by Ashin Guha Majumder
Ashin Guha Majumder
 

Viewers also liked (12)

PDF
Programming paradigm
Bhavin Kamani
 
PPTX
Programming Paradigm & Languages
Gaditek
 
PPTX
Prgramming paradigms
Anirudh Chauhan
 
PPT
Introduction to Functional Programming in JavaScript
tmont
 
PDF
那些 Functional Programming 教我的事
Wen-Tien Chang
 
PPTX
Functional Programming Fundamentals
Shahriar Hyder
 
PPTX
3Com 122-00605-000 05
savomir
 
DOCX
Presión atmosférica
Cesar Enoch
 
PPTX
Patient Academy Onderzoek 7 maart 2017
Marleen van Gelder
 
PPTX
Trabajo b.s.o disney
marta valiente campos
 
PPTX
Studio Voylla makes Falaknuma Palace its muse!
Voylla Fashion Pvt Ltd
 
Programming paradigm
Bhavin Kamani
 
Programming Paradigm & Languages
Gaditek
 
Prgramming paradigms
Anirudh Chauhan
 
Introduction to Functional Programming in JavaScript
tmont
 
那些 Functional Programming 教我的事
Wen-Tien Chang
 
Functional Programming Fundamentals
Shahriar Hyder
 
3Com 122-00605-000 05
savomir
 
Presión atmosférica
Cesar Enoch
 
Patient Academy Onderzoek 7 maart 2017
Marleen van Gelder
 
Trabajo b.s.o disney
marta valiente campos
 
Studio Voylla makes Falaknuma Palace its muse!
Voylla Fashion Pvt Ltd
 
Ad

Similar to Functional programming (20)

PPT
Functional Programming - Past, Present and Future
Pushkar Kulkarni
 
PPT
Functional Programming Past Present Future
IndicThreads
 
PDF
Functional programming
ijcd
 
PDF
Functional Programming #FTW
Adriano Bonat
 
PPT
Introduction Functional Programming - Tech Hangout #11 - 2013.01.16
Innovecs
 
PPT
Introductory func prog
Oleksandr Khomenko
 
PPS
Presentation of GetTogether on Functional Programming
Filip De Sutter
 
PPTX
Plc part 3
Taymoor Nazmy
 
PPTX
History fp
VeerapatBoonvanich1
 
PDF
Functional Programming and Haskell - TWBR Away Day 2011
Adriano Bonat
 
PDF
Introduction to functional programming (In Arabic)
Omar Abdelhafith
 
PDF
15 functional programming
jigeno
 
PDF
15 functional programming
jigeno
 
PPTX
PARADIGM IT.pptx
jamesmarken1
 
PDF
[FLOLAC'14][scm] Functional Programming Using Haskell
Functional Thursday
 
PDF
Lambda Calculus & Functional programming
Alexander Nemish
 
PPTX
Funtional Programming
Girish Khanzode
 
PPTX
Functional Programming.pptx
KarthickT28
 
PPT
Chapter1
Diego Facundo
 
PDF
Lambda? You Keep Using that Letter
Kevlin Henney
 
Functional Programming - Past, Present and Future
Pushkar Kulkarni
 
Functional Programming Past Present Future
IndicThreads
 
Functional programming
ijcd
 
Functional Programming #FTW
Adriano Bonat
 
Introduction Functional Programming - Tech Hangout #11 - 2013.01.16
Innovecs
 
Introductory func prog
Oleksandr Khomenko
 
Presentation of GetTogether on Functional Programming
Filip De Sutter
 
Plc part 3
Taymoor Nazmy
 
Functional Programming and Haskell - TWBR Away Day 2011
Adriano Bonat
 
Introduction to functional programming (In Arabic)
Omar Abdelhafith
 
15 functional programming
jigeno
 
15 functional programming
jigeno
 
PARADIGM IT.pptx
jamesmarken1
 
[FLOLAC'14][scm] Functional Programming Using Haskell
Functional Thursday
 
Lambda Calculus & Functional programming
Alexander Nemish
 
Funtional Programming
Girish Khanzode
 
Functional Programming.pptx
KarthickT28
 
Chapter1
Diego Facundo
 
Lambda? You Keep Using that Letter
Kevlin Henney
 
Ad

Recently uploaded (20)

PPTX
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
PDF
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PPTX
A Complete Guide to Salesforce SMS Integrations Build Scalable Messaging With...
360 SMS APP
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PDF
Executive Business Intelligence Dashboards
vandeslie24
 
DOCX
Import Data Form Excel to Tally Services
Tally xperts
 
PPTX
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PPTX
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 
PDF
Streamline Contractor Lifecycle- TECH EHS Solution
TECH EHS Solution
 
PPTX
The Role of a PHP Development Company in Modern Web Development
SEO Company for School in Delhi NCR
 
PDF
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
PPTX
Engineering the Java Web Application (MVC)
abhishekoza1981
 
PPTX
Feb 2021 Cohesity first pitch presentation.pptx
enginsayin1
 
PDF
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PPTX
Human Resources Information System (HRIS)
Amity University, Patna
 
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
A Complete Guide to Salesforce SMS Integrations Build Scalable Messaging With...
360 SMS APP
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Executive Business Intelligence Dashboards
vandeslie24
 
Import Data Form Excel to Tally Services
Tally xperts
 
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 
Streamline Contractor Lifecycle- TECH EHS Solution
TECH EHS Solution
 
The Role of a PHP Development Company in Modern Web Development
SEO Company for School in Delhi NCR
 
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
Engineering the Java Web Application (MVC)
abhishekoza1981
 
Feb 2021 Cohesity first pitch presentation.pptx
enginsayin1
 
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Human Resources Information System (HRIS)
Amity University, Patna
 

Functional programming

  • 2. What is a programming paradigm? A way of approaching code, data, and design. Imperative is thinking of code as blocks that run from top to bottom. Data is manipulated by storing and altering values. Object oriented is thinking of code as an interaction between objects Objects have behavior and data Event-driven The code responds to events and data changes as events happen
  • 3. The Functional Paradigm Code is a series of functions. Invocations of functions are the key operation. Functions are data types as well, so they can be accepted as parameters and returned from other functions (there will be examples). Data is always immutable - nothing can be changed, merely copied. Why? Easy to debug. Elegant. Concurrent.
  • 4. Some History on Paradigms Mathematicians tried to denote everything they could compute and people came up with their own systems. Turing came up with the universal Turing machine. Church helped develop lambda calculus. Curry helped with combinatory logic. The universal Turing machine happens to be the easiest to implement with current hardware.
  • 5. Lambda Calculus This is the mathematical foundation of functional programming. The entirety is two things: Calling functions (with 1 argument) Defining functions (with 1 argument) This is Turing complete. 𝜆x.x // This is the identity function 𝜆x.𝜆y.(y x) //Call the function “y” on some variable “x”.
  • 6. Alonzo Church Developed lambda calculus in the 1930s. Turing and Church proved that a Turing machine and lambda calculus are equivalent. The famous “Church-Turing thesis” Numbers in lambda calculus are “Church numerals”. 𝜆f.𝜆x.x = 0 (and false) 𝜆n.𝜆f.𝜆x.((n f) x) = succ n = n + 1
  • 7. Haskell Curry Made Combinatory Logic (similar to lambda calculus). Has Haskell named after him. Currying is also named after him (but he didn’t make it). Currying lets you make n-argument functions from 1-argument functions. 𝜆f.𝜆x.x = 𝜆f x.x //This is well-defined by Currying. The outer lambdas return a function and the last one returns a value. ((𝜆n m.(n + m)) 4 5) = ((𝜆n.𝜆m.(n + m) 4) 5) = (𝜆m.(4 + m) 5) = 4 + 5 = 9
  • 8. Examples: Into the Clojure The syntax of this language is very simple (non-existent). (<thing being called> <val1> … <val n>) This is a mean: “(/ (+ x y) 2)” This is the quadratic formula: (the colorful parens are called rainbow parens) (/ (+ (* -1 b) (Math/sqrt (- (* b b) (* 4 a c)))) (* 2 a)) This is a simple checker for evenness: (if (= 0 (mod x 2)) true false) http://www.tryclj.com/
  • 12. Doin’ it live! Newton’s method solver given an error bound, a function and a function that is its derivative. Make it return a function that accepts a starting point.
  • 13. Google Searches Languages Haskell Scheme F# Common Lisp OCamL Clojure Other languages also have good support: C#, C++, Java Concepts Streams (or generators, iterators) Variable capture Monads Functors