What functional programming means to me
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

What functional programming means to me

on

  • 1,916 views

The assignment for Functional Brighton Meet up was to describe what functional programming means to you...

The assignment for Functional Brighton Meet up was to describe what functional programming means to you...

Statistics

Views

Total Views
1,916
Views on SlideShare
607
Embed Views
1,309

Actions

Likes
1
Downloads
17
Comments
0

8 Embeds 1,309

http://richard.dallaway.com 1282
http://posterous.com 9
http://www.linkedin.com 6
https://www.linkedin.com 4
http://static.slidesharecdn.com 3
https://dallaway.telegr.am 3
http://lj-toys.com 1
https://posterous.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

What functional programming means to me Presentation Transcript

  • 1. Three things I’ve noticed aboutfunctional programming while using Scala.
  • 2. What have we have? What do we want? happy birthday tohappy birthday to me me #lol #omg oops #lol oops #lol #omg ⋮ ⋮
  • 3. What have we have? What do we want? #lol, #omg Some text & some text
  • 4. What have we have? What do we want? #lol, #omg Some text & some text List[String], String String
  • 5. def appendTags(tweet: String, tags: List[String]) = tags.foldLeft(tweet) { appendOne }def appendOne(tweet: String, tag: String) = if (tweet contains tag) tweet else tweet+" "+tag
  • 6. StringBuffer b = new StringBuffer(tweet);if (tags != null) { for(String tag: tags) { if (tag != null && b.indexOf(tag) == -1) { b.append(tag).append(“ ”); } }}return b.toString();
  • 7. “It’s the mutable state, stupid.” – Göetz et al.
  • 8. val results = List(yahoo _, google _).par.map(_.apply)
  • 9. import scala.actors.Futures._val results = List(yahoo _, google _) map ( f future{ f() } ) map (_.apply)
  • 10. Option, for comprehensions,flatMap & pattern matching are astonishingly useful every day and I’d never heard of them before learning Scala.
  • 11. for (int i = 0; i < resultFeed.getEntries().size(); i++) {   ContactEntry entry = resultFeed.getEntries().get(i);      if (entry.hasName()) {        Name name = entry.getName();        if (name.hasFullName()) {        ...  
  • 12. for { entry ← resultFeed.getEntries       name ← Option(entry.getName)       full_name ← Option(name.getFullName)       birthday ← Option(entry.getBirthday)   }  yield "%s: %s".format(full_name.getValue, when) 
  • 13. Summary1. Thinking in terms of A B2. Concurrency3. Option (& friends) change everything