Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

Like this presentation? Why not share!

- HN NL - Haskell by chriseidhof 910 views
- Iglesia de San Nicolás. Un monument... by La Gatera de la V... 282 views
- Reasonable RPC with Remotely by Timothy Perrett 676 views
- Web programming in Haskell by chriseidhof 1150 views
- Compositional I/O Stream in Scala by C4Media 628 views
- Haskell for Scala-ists by chriseidhof 1792 views

2,136 views

Published on

No Downloads

Total views

2,136

On SlideShare

0

From Embeds

0

Number of Embeds

43

Shares

0

Downloads

78

Comments

0

Likes

5

No embeds

No notes for slide

- 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. Inﬁnite lists... primes = sieve [2 . . ] sieve (p : xs) = p : sieve [x | x ← xs , x ‘mod‘ p ≡ 0 ]
- 12. QuickSort qsort [ ] = [] qsort (x : xs) = qsort (ﬁlter (<x) xs) + [x ] + + qsort (ﬁlter ( 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

No public clipboards found for this slide

×
### Save the most important slides with Clipping

Clipping is a handy way to collect and organize the most important slides from a presentation. You can keep your great finds in clipboards organized around topics.

Be the first to comment