SlideShare a Scribd company logo
1 of 16
Download to read offline
Functional Programming
  Chris Eidhof    Eelco Lempsink


    Amsterdam.rb, October 27, 2008



         ( tp
         , ui
          ) l
Functional programming in Ruby




(1..4).collect {|i| i*i }
 #=> [1, 4, 9, 16]

(1..10).inject {|sum, n| sum + n}
 #=> 55
Functional programming with Haskell



(1..4).collect {|i| i*i }


  map (λi → i ∗ i) [1 . . 4] -- [1,4,9,16]


(1..10).inject {|sum, n| sum + n}


  foldr (λn sum → sum + n) 0 [1 . . 10] -- 55
What is Haskell?




Haskell is a
  • strongly typed
  • lazy
  • purely functional
programming language
Everything is a function


• No “assignment”
• Referential transparancy
• Partial application, no parentheses needed


  a=5
  a=6     -- Invalid!



  squares xs = map (λx → x ∗ x) xs
Why should I learn Haskell?




• Functional Programming gives you a fresh way to look at
  problems
• Even if you don’t use a functional language
• Python, Ruby, C# all use ideas from FP
• Google’s Map/Reduce and Hadoop are large scale FP
Lists




data [a] = [ ]
         | a : [a]
Some standard functions



sum [ ]          =0
sum (x : xs)     = x + sum xs


product [ ]      =1
product (x : xs) = x ∗ product xs


and [ ]          = True
and (x : xs)     = x ∧ and xs
Everything is a fold!




foldr (⊕) e [ ]      =e
foldr (⊕) e (x : xs) = x ⊕ (foldr (⊕) e xs)



sum     = foldr ( + ) 0
product = foldr ( ∗ ) 1
and     = foldr ( ∧ ) True
Even map!




map f = foldr (λx tail → (f x) : tail) [ ]
Infinite lists...




primes         = sieve [2 . . ]
sieve (p : xs) = p : sieve [x | x ← xs
                                , x ‘mod‘ p ≡ 0
                           ]
QuickSort




qsort [ ]      = []
qsort (x : xs) = qsort (filter (<x) xs)
               + [x ]
               +
               + qsort (filter ( x) xs)
               +
What we didn’t tell you




• Function composition
• Types
• Purity and I/O
• Monads
• Foreign Function Interface
• ...
Haskell in the Real World




• Large applications (XMonad, Darcs, GHC, Yi)
• Lots of libraries (Today on hackage: 814 libraries and
  programs)
• Used by large companies (Credit Suisse, Galois, Microsoft,
  ABN Amro . . . )
• Lots of ways to learn Haskell ((free) textbooks, university
  courses, haskell wiki, blogs)
Functional programming




• ... sharpens your brain
• ... is lots of fun
• ... can help you become a better programmer
More information




• http://haskell.org
• http://hackage.haskell.org
• http://book.realworldhaskell.org/
• http://tupil.com

More Related Content

What's hot

Functional Programming, simplified
Functional Programming, simplifiedFunctional Programming, simplified
Functional Programming, simplifiedNaveenkumar Muguda
 
La R Users Group Survey Of R Graphics
La R Users Group Survey Of R GraphicsLa R Users Group Survey Of R Graphics
La R Users Group Survey Of R Graphicsguest43ed8709
 
Gopher conbr golang e data science - oficial
Gopher conbr   golang e data science - oficialGopher conbr   golang e data science - oficial
Gopher conbr golang e data science - oficialRodrigo Pinheiro
 
R - Basic Introduction
R - Basic IntroductionR - Basic Introduction
R - Basic IntroductionKU by ADDI
 
Haskell for Scala-ists
Haskell for Scala-istsHaskell for Scala-ists
Haskell for Scala-istschriseidhof
 
What Haskell taught us when we were not looking! - Eric Torreborre - Codemoti...
What Haskell taught us when we were not looking! - Eric Torreborre - Codemoti...What Haskell taught us when we were not looking! - Eric Torreborre - Codemoti...
What Haskell taught us when we were not looking! - Eric Torreborre - Codemoti...Codemotion
 
Coderstrust Presentation on C Language
Coderstrust Presentation on C LanguageCoderstrust Presentation on C Language
Coderstrust Presentation on C LanguageSrabon Sabbir
 
Visualization team presentation
Visualization team presentation Visualization team presentation
Visualization team presentation madhobilota
 
Rumus VB Menghitung Nilai Persamaan
Rumus VB Menghitung Nilai PersamaanRumus VB Menghitung Nilai Persamaan
Rumus VB Menghitung Nilai PersamaanT. Astari
 
Tools for research plotting
Tools for research plottingTools for research plotting
Tools for research plottingNimrita Koul
 
Javascript Libraries & Frameworks | Connor Goddard
Javascript Libraries & Frameworks | Connor GoddardJavascript Libraries & Frameworks | Connor Goddard
Javascript Libraries & Frameworks | Connor GoddardConnor Goddard
 
HelsinkiOS Jan 2015: Useful iOS Code Snippets
HelsinkiOS Jan 2015: Useful iOS Code SnippetsHelsinkiOS Jan 2015: Useful iOS Code Snippets
HelsinkiOS Jan 2015: Useful iOS Code SnippetsJouni Miettunen
 
Animaton Package in R An Example:
Animaton Package in R An Example:Animaton Package in R An Example:
Animaton Package in R An Example:Dr. Volkan OBAN
 

What's hot (19)

Functional Programming, simplified
Functional Programming, simplifiedFunctional Programming, simplified
Functional Programming, simplified
 
Cache and Drupal
Cache and DrupalCache and Drupal
Cache and Drupal
 
La R Users Group Survey Of R Graphics
La R Users Group Survey Of R GraphicsLa R Users Group Survey Of R Graphics
La R Users Group Survey Of R Graphics
 
Logging in JavaScript - Part-5
Logging in JavaScript - Part-5Logging in JavaScript - Part-5
Logging in JavaScript - Part-5
 
Gopher conbr golang e data science - oficial
Gopher conbr   golang e data science - oficialGopher conbr   golang e data science - oficial
Gopher conbr golang e data science - oficial
 
R - Basic Introduction
R - Basic IntroductionR - Basic Introduction
R - Basic Introduction
 
Haskell for Scala-ists
Haskell for Scala-istsHaskell for Scala-ists
Haskell for Scala-ists
 
What Haskell taught us when we were not looking! - Eric Torreborre - Codemoti...
What Haskell taught us when we were not looking! - Eric Torreborre - Codemoti...What Haskell taught us when we were not looking! - Eric Torreborre - Codemoti...
What Haskell taught us when we were not looking! - Eric Torreborre - Codemoti...
 
Coderstrust Presentation on C Language
Coderstrust Presentation on C LanguageCoderstrust Presentation on C Language
Coderstrust Presentation on C Language
 
201801 CSE240 Lecture 20
201801 CSE240 Lecture 20201801 CSE240 Lecture 20
201801 CSE240 Lecture 20
 
Visualization team presentation
Visualization team presentation Visualization team presentation
Visualization team presentation
 
Rumus VB Menghitung Nilai Persamaan
Rumus VB Menghitung Nilai PersamaanRumus VB Menghitung Nilai Persamaan
Rumus VB Menghitung Nilai Persamaan
 
Tools for research plotting
Tools for research plottingTools for research plotting
Tools for research plotting
 
Javascript Libraries & Frameworks | Connor Goddard
Javascript Libraries & Frameworks | Connor GoddardJavascript Libraries & Frameworks | Connor Goddard
Javascript Libraries & Frameworks | Connor Goddard
 
HelsinkiOS Jan 2015: Useful iOS Code Snippets
HelsinkiOS Jan 2015: Useful iOS Code SnippetsHelsinkiOS Jan 2015: Useful iOS Code Snippets
HelsinkiOS Jan 2015: Useful iOS Code Snippets
 
C# 6.0
C# 6.0C# 6.0
C# 6.0
 
Python Set.pptx
Python Set.pptxPython Set.pptx
Python Set.pptx
 
Animaton Package in R An Example:
Animaton Package in R An Example:Animaton Package in R An Example:
Animaton Package in R An Example:
 
Python at 10.1
Python at 10.1Python at 10.1
Python at 10.1
 

Viewers also liked

Iglesia de San Nicolás. Un monumento árabe en Madrid
Iglesia de San Nicolás. Un monumento árabe en MadridIglesia de San Nicolás. Un monumento árabe en Madrid
Iglesia de San Nicolás. Un monumento árabe en MadridLa Gatera de la Villa
 
Reasonable RPC with Remotely
Reasonable RPC with RemotelyReasonable RPC with Remotely
Reasonable RPC with RemotelyTimothy Perrett
 
Web programming in Haskell
Web programming in HaskellWeb programming in Haskell
Web programming in Haskellchriseidhof
 
Compositional I/O Stream in Scala
Compositional I/O Stream in ScalaCompositional I/O Stream in Scala
Compositional I/O Stream in ScalaC4Media
 
Haskell for Scala-ists
Haskell for Scala-istsHaskell for Scala-ists
Haskell for Scala-istschriseidhof
 
Visualising Data on Interactive Maps
Visualising Data on Interactive MapsVisualising Data on Interactive Maps
Visualising Data on Interactive MapsAnna Pawlicka
 
Caching In The Cloud
Caching In The CloudCaching In The Cloud
Caching In The CloudAlex Miller
 
Groovy concurrency
Groovy concurrencyGroovy concurrency
Groovy concurrencyAlex Miller
 
Scaling Your Cache
Scaling Your CacheScaling Your Cache
Scaling Your CacheAlex Miller
 
Stream Execution with Clojure and Fork/join
Stream Execution with Clojure and Fork/joinStream Execution with Clojure and Fork/join
Stream Execution with Clojure and Fork/joinAlex Miller
 
Scaling Hibernate with Terracotta
Scaling Hibernate with TerracottaScaling Hibernate with Terracotta
Scaling Hibernate with TerracottaAlex Miller
 
Project Fortress
Project FortressProject Fortress
Project FortressAlex Miller
 
Cracking clojure
Cracking clojureCracking clojure
Cracking clojureAlex Miller
 
Purely Functional I/O
Purely Functional I/OPurely Functional I/O
Purely Functional I/OC4Media
 
Java Concurrency Gotchas
Java Concurrency GotchasJava Concurrency Gotchas
Java Concurrency GotchasAlex Miller
 
Clojure: The Art of Abstraction
Clojure: The Art of AbstractionClojure: The Art of Abstraction
Clojure: The Art of AbstractionAlex Miller
 

Viewers also liked (20)

Iglesia de San Nicolás. Un monumento árabe en Madrid
Iglesia de San Nicolás. Un monumento árabe en MadridIglesia de San Nicolás. Un monumento árabe en Madrid
Iglesia de San Nicolás. Un monumento árabe en Madrid
 
Reasonable RPC with Remotely
Reasonable RPC with RemotelyReasonable RPC with Remotely
Reasonable RPC with Remotely
 
Web programming in Haskell
Web programming in HaskellWeb programming in Haskell
Web programming in Haskell
 
HN NL - Haskell
HN NL - HaskellHN NL - Haskell
HN NL - Haskell
 
Compositional I/O Stream in Scala
Compositional I/O Stream in ScalaCompositional I/O Stream in Scala
Compositional I/O Stream in Scala
 
Haskell for Scala-ists
Haskell for Scala-istsHaskell for Scala-ists
Haskell for Scala-ists
 
Visualising Data on Interactive Maps
Visualising Data on Interactive MapsVisualising Data on Interactive Maps
Visualising Data on Interactive Maps
 
Beyond Mere Actors
Beyond Mere ActorsBeyond Mere Actors
Beyond Mere Actors
 
Caching In The Cloud
Caching In The CloudCaching In The Cloud
Caching In The Cloud
 
Blogging ZOMG
Blogging ZOMGBlogging ZOMG
Blogging ZOMG
 
Groovy concurrency
Groovy concurrencyGroovy concurrency
Groovy concurrency
 
Cold Hard Cache
Cold Hard CacheCold Hard Cache
Cold Hard Cache
 
Scaling Your Cache
Scaling Your CacheScaling Your Cache
Scaling Your Cache
 
Stream Execution with Clojure and Fork/join
Stream Execution with Clojure and Fork/joinStream Execution with Clojure and Fork/join
Stream Execution with Clojure and Fork/join
 
Scaling Hibernate with Terracotta
Scaling Hibernate with TerracottaScaling Hibernate with Terracotta
Scaling Hibernate with Terracotta
 
Project Fortress
Project FortressProject Fortress
Project Fortress
 
Cracking clojure
Cracking clojureCracking clojure
Cracking clojure
 
Purely Functional I/O
Purely Functional I/OPurely Functional I/O
Purely Functional I/O
 
Java Concurrency Gotchas
Java Concurrency GotchasJava Concurrency Gotchas
Java Concurrency Gotchas
 
Clojure: The Art of Abstraction
Clojure: The Art of AbstractionClojure: The Art of Abstraction
Clojure: The Art of Abstraction
 

Similar to Functional Programming

Five Languages in a Moment
Five Languages in a MomentFive Languages in a Moment
Five Languages in a MomentSergio Gil
 
Haskell - Being lazy with class
Haskell - Being lazy with classHaskell - Being lazy with class
Haskell - Being lazy with classTiago Babo
 
Yin Yangs of Software Development
Yin Yangs of Software DevelopmentYin Yangs of Software Development
Yin Yangs of Software DevelopmentNaveenkumar Muguda
 
Beauty and the beast - Haskell on JVM
Beauty and the beast  - Haskell on JVMBeauty and the beast  - Haskell on JVM
Beauty and the beast - Haskell on JVMJarek Ratajski
 
Why Haskell Matters
Why Haskell MattersWhy Haskell Matters
Why Haskell Mattersromanandreg
 
Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?osfameron
 
Introduction to Scalding and Monoids
Introduction to Scalding and MonoidsIntroduction to Scalding and Monoids
Introduction to Scalding and MonoidsHugo Gävert
 
Emerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the HorizonEmerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the HorizonAlex Payne
 
Haskell retrospective
Haskell retrospectiveHaskell retrospective
Haskell retrospectivechenge2k
 
Ruslan.shevchenko: most functional-day-kiev 2014
Ruslan.shevchenko: most functional-day-kiev 2014Ruslan.shevchenko: most functional-day-kiev 2014
Ruslan.shevchenko: most functional-day-kiev 2014Ruslan Shevchenko
 
Introduction to Haskell: 2011-04-13
Introduction to Haskell: 2011-04-13Introduction to Haskell: 2011-04-13
Introduction to Haskell: 2011-04-13Jay Coskey
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 
Real World Haskell: Lecture 1
Real World Haskell: Lecture 1Real World Haskell: Lecture 1
Real World Haskell: Lecture 1Bryan O'Sullivan
 
Scala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghScala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghStuart Roebuck
 
Introduction to meta-programming in scala
Introduction to meta-programming in scalaIntroduction to meta-programming in scala
Introduction to meta-programming in scalaAlessandro Marrella
 
From Java to Scala - advantages and possible risks
From Java to Scala - advantages and possible risksFrom Java to Scala - advantages and possible risks
From Java to Scala - advantages and possible risksSeniorDevOnly
 

Similar to Functional Programming (20)

Five Languages in a Moment
Five Languages in a MomentFive Languages in a Moment
Five Languages in a Moment
 
Haskell - Being lazy with class
Haskell - Being lazy with classHaskell - Being lazy with class
Haskell - Being lazy with class
 
Yin Yangs of Software Development
Yin Yangs of Software DevelopmentYin Yangs of Software Development
Yin Yangs of Software Development
 
Beauty and the beast - Haskell on JVM
Beauty and the beast  - Haskell on JVMBeauty and the beast  - Haskell on JVM
Beauty and the beast - Haskell on JVM
 
Eta
EtaEta
Eta
 
Haskell
HaskellHaskell
Haskell
 
01. haskell introduction
01. haskell introduction01. haskell introduction
01. haskell introduction
 
Why Haskell Matters
Why Haskell MattersWhy Haskell Matters
Why Haskell Matters
 
04. haskell handling
04. haskell handling04. haskell handling
04. haskell handling
 
Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?
 
Introduction to Scalding and Monoids
Introduction to Scalding and MonoidsIntroduction to Scalding and Monoids
Introduction to Scalding and Monoids
 
Emerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the HorizonEmerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the Horizon
 
Haskell retrospective
Haskell retrospectiveHaskell retrospective
Haskell retrospective
 
Ruslan.shevchenko: most functional-day-kiev 2014
Ruslan.shevchenko: most functional-day-kiev 2014Ruslan.shevchenko: most functional-day-kiev 2014
Ruslan.shevchenko: most functional-day-kiev 2014
 
Introduction to Haskell: 2011-04-13
Introduction to Haskell: 2011-04-13Introduction to Haskell: 2011-04-13
Introduction to Haskell: 2011-04-13
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Real World Haskell: Lecture 1
Real World Haskell: Lecture 1Real World Haskell: Lecture 1
Real World Haskell: Lecture 1
 
Scala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghScala @ TechMeetup Edinburgh
Scala @ TechMeetup Edinburgh
 
Introduction to meta-programming in scala
Introduction to meta-programming in scalaIntroduction to meta-programming in scala
Introduction to meta-programming in scala
 
From Java to Scala - advantages and possible risks
From Java to Scala - advantages and possible risksFrom Java to Scala - advantages and possible risks
From Java to Scala - advantages and possible risks
 

Recently uploaded

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Recently uploaded (20)

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 

Functional Programming

  • 1. Functional Programming Chris Eidhof Eelco Lempsink Amsterdam.rb, October 27, 2008 ( tp , ui ) l
  • 2. Functional programming in Ruby (1..4).collect {|i| i*i } #=> [1, 4, 9, 16] (1..10).inject {|sum, n| sum + n} #=> 55
  • 3. Functional programming with Haskell (1..4).collect {|i| i*i } map (λi → i ∗ i) [1 . . 4] -- [1,4,9,16] (1..10).inject {|sum, n| sum + n} foldr (λn sum → sum + n) 0 [1 . . 10] -- 55
  • 4. What is Haskell? Haskell is a • strongly typed • lazy • purely functional programming language
  • 5. Everything is a function • No “assignment” • Referential transparancy • Partial application, no parentheses needed a=5 a=6 -- Invalid! squares xs = map (λx → x ∗ x) xs
  • 6. Why should I learn Haskell? • Functional Programming gives you a fresh way to look at problems • Even if you don’t use a functional language • Python, Ruby, C# all use ideas from FP • Google’s Map/Reduce and Hadoop are large scale FP
  • 7. Lists data [a] = [ ] | a : [a]
  • 8. Some standard functions sum [ ] =0 sum (x : xs) = x + sum xs product [ ] =1 product (x : xs) = x ∗ product xs and [ ] = True and (x : xs) = x ∧ and xs
  • 9. Everything is a fold! foldr (⊕) e [ ] =e foldr (⊕) e (x : xs) = x ⊕ (foldr (⊕) e xs) sum = foldr ( + ) 0 product = foldr ( ∗ ) 1 and = foldr ( ∧ ) True
  • 10. Even map! map f = foldr (λx tail → (f x) : tail) [ ]
  • 11. Infinite lists... primes = sieve [2 . . ] sieve (p : xs) = p : sieve [x | x ← xs , x ‘mod‘ p ≡ 0 ]
  • 12. QuickSort qsort [ ] = [] qsort (x : xs) = qsort (filter (<x) xs) + [x ] + + qsort (filter ( x) xs) +
  • 13. What we didn’t tell you • Function composition • Types • Purity and I/O • Monads • Foreign Function Interface • ...
  • 14. Haskell in the Real World • Large applications (XMonad, Darcs, GHC, Yi) • Lots of libraries (Today on hackage: 814 libraries and programs) • Used by large companies (Credit Suisse, Galois, Microsoft, ABN Amro . . . ) • Lots of ways to learn Haskell ((free) textbooks, university courses, haskell wiki, blogs)
  • 15. Functional programming • ... sharpens your brain • ... is lots of fun • ... can help you become a better programmer
  • 16. More information • http://haskell.org • http://hackage.haskell.org • http://book.realworldhaskell.org/ • http://tupil.com