SlideShare uma empresa Scribd logo
1 de 16
Functional Programming
          - Introducing F#



                     06/15/2012
Example
 Give me a list of numbers from 1 to 100.




    Tell me how ?             Tell me what ?
What?
Functional programming is a programming paradigm
that treats computation as the evaluation of
mathematical functions and avoids state and mutable
data.


                      y = f (x)
A function is a transformation. It transforms one or more inputs into exactly
one output.
Why?
 Succinct & simpler programs
   Small code base, low dev/maintenance cost.


 A number of powerful new ways to structure and
 reason about programs.
   Immutability
   High order function
   Pattern Matching
  …
How?

 Immutability
 Type Inference
 Recursion
 High Order Functions
 Partial Application
 Pattern Matching
 Unit of Measure
Immutability
By default, values are immutable. Use keyword
mutable to mark it as mutable.
Type Inference
 F# can deduce data types automatically.
 Type annotation is necessary in certain case.
Recursion
• Functional programming prefers recursion to
  imperative for-each loops.

• Prefer tail recursion to avoid stack overflow
High order Function
 Functions in F#
High order Function
 Functions as First Class Member
 Functions that accept a function as a parameter or
 returns a function
High Order Function

 Map
 Fold
 Zip
 Filter
 Pipeline
 Function Composition
 Partial Application
Pattern Match
 Compare data with a logical structure
 Decompose data into its constituent parts
 Extract information from constructs in various
 ways
Unit of Measure
 Floating point and signed integer values in F# can
  have associated units of measure.
 Compile time checking.
Functional Programming in Real World
 Erlang developed in Ericsson widely used in T-
  Mobile, Facebook....
 Industry
   Communication
   Finance industry
   Scientific computation
   AI

 Languages support FP
   Haskell
   Scala
   Python
   Clojure
   …
Resources
 The F# Survival Guide
 Functional Programming for the Real World
Functional programming   f#

Mais conteúdo relacionado

Mais procurados

Computer Organization and Architecture Overview
Computer Organization and Architecture OverviewComputer Organization and Architecture Overview
Computer Organization and Architecture OverviewDhaval Bagal
 
Interpretable ML
Interpretable MLInterpretable ML
Interpretable MLMayur Sand
 
Feature Engineering & Selection
Feature Engineering & SelectionFeature Engineering & Selection
Feature Engineering & SelectionEng Teong Cheah
 
Math Editing and display using Microsoft Office 2007 System
Math Editing and display using Microsoft Office 2007 System Math Editing and display using Microsoft Office 2007 System
Math Editing and display using Microsoft Office 2007 System Severus Prime
 
Math Functions in C Scanf Printf
Math Functions in C Scanf PrintfMath Functions in C Scanf Printf
Math Functions in C Scanf Printfyarkhosh
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design PatternSalem-Kabbani
 
Templates c++ - prashant odhavani - 160920107003
Templates   c++ - prashant odhavani - 160920107003Templates   c++ - prashant odhavani - 160920107003
Templates c++ - prashant odhavani - 160920107003Prashant odhavani
 
System approach in civil engg slideshare.vvs
System approach in civil engg slideshare.vvsSystem approach in civil engg slideshare.vvs
System approach in civil engg slideshare.vvsvrushali sasane
 
Basic Algorithm @PPSC(1)
Basic Algorithm @PPSC(1)Basic Algorithm @PPSC(1)
Basic Algorithm @PPSC(1)Amiya Bhusan
 
Linear programming optimization in r
Linear programming optimization in r Linear programming optimization in r
Linear programming optimization in r Ashwini Mathur
 
Introduction to-programming
Introduction to-programmingIntroduction to-programming
Introduction to-programmingPTtp WgWt
 

Mais procurados (14)

Computer Organization and Architecture Overview
Computer Organization and Architecture OverviewComputer Organization and Architecture Overview
Computer Organization and Architecture Overview
 
Interpretable ML
Interpretable MLInterpretable ML
Interpretable ML
 
Feature Engineering & Selection
Feature Engineering & SelectionFeature Engineering & Selection
Feature Engineering & Selection
 
Math Editing and display using Microsoft Office 2007 System
Math Editing and display using Microsoft Office 2007 System Math Editing and display using Microsoft Office 2007 System
Math Editing and display using Microsoft Office 2007 System
 
Excel
ExcelExcel
Excel
 
Csc240 -lecture_5
Csc240  -lecture_5Csc240  -lecture_5
Csc240 -lecture_5
 
Math Functions in C Scanf Printf
Math Functions in C Scanf PrintfMath Functions in C Scanf Printf
Math Functions in C Scanf Printf
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
 
Templates c++ - prashant odhavani - 160920107003
Templates   c++ - prashant odhavani - 160920107003Templates   c++ - prashant odhavani - 160920107003
Templates c++ - prashant odhavani - 160920107003
 
hjlhjljkl
hjlhjljklhjlhjljkl
hjlhjljkl
 
System approach in civil engg slideshare.vvs
System approach in civil engg slideshare.vvsSystem approach in civil engg slideshare.vvs
System approach in civil engg slideshare.vvs
 
Basic Algorithm @PPSC(1)
Basic Algorithm @PPSC(1)Basic Algorithm @PPSC(1)
Basic Algorithm @PPSC(1)
 
Linear programming optimization in r
Linear programming optimization in r Linear programming optimization in r
Linear programming optimization in r
 
Introduction to-programming
Introduction to-programmingIntroduction to-programming
Introduction to-programming
 

Semelhante a Functional programming f#

Functional Paradigm.pptx
Functional Paradigm.pptxFunctional Paradigm.pptx
Functional Paradigm.pptxFurretMaster
 
Why functional programming in C# & F#
Why functional programming in C# & F#Why functional programming in C# & F#
Why functional programming in C# & F#Riccardo Terrell
 
Succeeding with Functional-first Programming in Enterprise
Succeeding with Functional-first Programming in EnterpriseSucceeding with Functional-first Programming in Enterprise
Succeeding with Functional-first Programming in Enterprisedsyme
 
Functional programming
Functional programmingFunctional programming
Functional programmingPiumiPerera7
 
Programming in c++ ppt
Programming in c++ pptProgramming in c++ ppt
Programming in c++ pptsujathavvv
 
Programming in c++ ppt
Programming in c++ pptProgramming in c++ ppt
Programming in c++ pptMalarMohana
 
Functional programming in TypeScript
Functional programming in TypeScriptFunctional programming in TypeScript
Functional programming in TypeScriptbinDebug WorkSpace
 
Functions in c
Functions in cFunctions in c
Functions in creshmy12
 
Introduction to functional programming
Introduction to functional programmingIntroduction to functional programming
Introduction to functional programmingKonrad Szydlo
 
VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1YOGESH SINGH
 
Functional programming
Functional programmingFunctional programming
Functional programmingKibru Demeke
 
Functional Programming in Ruby
Functional Programming in RubyFunctional Programming in Ruby
Functional Programming in RubyAlex Teut
 
Functions in c++, presentation, short and sweet presentation, and details of ...
Functions in c++, presentation, short and sweet presentation, and details of ...Functions in c++, presentation, short and sweet presentation, and details of ...
Functions in c++, presentation, short and sweet presentation, and details of ...Sar
 
Python functional programming
Python functional programmingPython functional programming
Python functional programmingGeison Goes
 
Concepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming LanguagesConcepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming Languagesppd1961
 
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...Skills Matter
 

Semelhante a Functional programming f# (20)

Functional Paradigm.pptx
Functional Paradigm.pptxFunctional Paradigm.pptx
Functional Paradigm.pptx
 
Prgramming paradigms
Prgramming paradigmsPrgramming paradigms
Prgramming paradigms
 
Why functional programming in C# & F#
Why functional programming in C# & F#Why functional programming in C# & F#
Why functional programming in C# & F#
 
Functional Ruby
Functional RubyFunctional Ruby
Functional Ruby
 
Succeeding with Functional-first Programming in Enterprise
Succeeding with Functional-first Programming in EnterpriseSucceeding with Functional-first Programming in Enterprise
Succeeding with Functional-first Programming in Enterprise
 
Functional programming
Functional programmingFunctional programming
Functional programming
 
Programming in c++ ppt
Programming in c++ pptProgramming in c++ ppt
Programming in c++ ppt
 
Programming in c++ ppt
Programming in c++ pptProgramming in c++ ppt
Programming in c++ ppt
 
Functional programming in TypeScript
Functional programming in TypeScriptFunctional programming in TypeScript
Functional programming in TypeScript
 
Functions in c
Functions in cFunctions in c
Functions in c
 
Introduction to functional programming
Introduction to functional programmingIntroduction to functional programming
Introduction to functional programming
 
VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1
 
arrays.ppt
arrays.pptarrays.ppt
arrays.ppt
 
Functional programming
Functional programmingFunctional programming
Functional programming
 
Functional Programming in Ruby
Functional Programming in RubyFunctional Programming in Ruby
Functional Programming in Ruby
 
Functions in c++, presentation, short and sweet presentation, and details of ...
Functions in c++, presentation, short and sweet presentation, and details of ...Functions in c++, presentation, short and sweet presentation, and details of ...
Functions in c++, presentation, short and sweet presentation, and details of ...
 
Python functional programming
Python functional programmingPython functional programming
Python functional programming
 
Concepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming LanguagesConcepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming Languages
 
1 puc programming using c++
1 puc programming using c++1 puc programming using c++
1 puc programming using c++
 
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
 

Último

DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 

Último (20)

DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 

Functional programming f#

  • 1. Functional Programming - Introducing F# 06/15/2012
  • 2. Example  Give me a list of numbers from 1 to 100. Tell me how ? Tell me what ?
  • 3. What? Functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. y = f (x) A function is a transformation. It transforms one or more inputs into exactly one output.
  • 4. Why?  Succinct & simpler programs  Small code base, low dev/maintenance cost.  A number of powerful new ways to structure and reason about programs.  Immutability  High order function  Pattern Matching …
  • 5. How?  Immutability  Type Inference  Recursion  High Order Functions  Partial Application  Pattern Matching  Unit of Measure
  • 6. Immutability By default, values are immutable. Use keyword mutable to mark it as mutable.
  • 7. Type Inference  F# can deduce data types automatically.  Type annotation is necessary in certain case.
  • 8. Recursion • Functional programming prefers recursion to imperative for-each loops. • Prefer tail recursion to avoid stack overflow
  • 9. High order Function  Functions in F#
  • 10. High order Function  Functions as First Class Member  Functions that accept a function as a parameter or returns a function
  • 11. High Order Function  Map  Fold  Zip  Filter  Pipeline  Function Composition  Partial Application
  • 12. Pattern Match  Compare data with a logical structure  Decompose data into its constituent parts  Extract information from constructs in various ways
  • 13. Unit of Measure  Floating point and signed integer values in F# can have associated units of measure.  Compile time checking.
  • 14. Functional Programming in Real World  Erlang developed in Ericsson widely used in T- Mobile, Facebook....  Industry  Communication  Finance industry  Scientific computation  AI  Languages support FP  Haskell  Scala  Python  Clojure  …
  • 15. Resources  The F# Survival Guide  Functional Programming for the Real World