Introduction to Functional Programming in Scala

762
-1

Published on

Presentation from my talk at JEEConf (http://jeeconf.com) in Kiev, Ukraine on 24th of May, 2013

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
762
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
22
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Introduction to Functional Programming in Scala

  1. 1. Functional Programmingwith ScalaIntroduction by @JacekLaskowski
  2. 2. Jacek Laskowski@JacekLaskowskihttp://blog.japila.pl
  3. 3. HTTPS://GITHUB.COM/PCHIUSANO/FPINSCALA
  4. 4. HTTP://WWW.ATOMICSCALA.COM/
  5. 5. HTTPS://WWW.COURSERA.ORG/COURSE/PROGFUN
  6. 6. Functional programmingIn computer science, functional programmingis a programming paradigm that treatscomputation as the evaluation ofmathematical functions and avoids state andmutable data. It emphasizes the application offunctions, in contrast to the imperative programmingstyle, which emphasizes changes in state.HTTP://EN.WIKIPEDIA.ORG/WIKI/FUNCTIONAL_PROGRAMMING
  7. 7. Functional programming•Programming paradigm•Computation = function evaluation•Avoids state and mutable data•Function composition•Expressions everywhere
  8. 8. Scala is a modern multi-paradigmprogramming language designed to expresscommon programming patterns in a concise, elegant,and type-safe way. It smoothly integrates featuresof object-oriented and functional languages.HTTP://WWW.SCALA-LANG.ORG/NODE/104Scala is also a functional languagein the sense that every function is avalue.
  9. 9. Keyword todefine a MethodMethod’s nameMethod’s inputparameters andtheir typesMethod’sreturn type(optional)Method’s body
  10. 10. Expression vs statement•A statement changes state•it’s called for side effects•An expression produces resultFROM “ATOMIC SCALA” BY BRUCE ECKEL AND DIANNE MARSH
  11. 11. Everything in Scala is anexpression
  12. 12. Is this an expression?YES!Is this an expression?YES!
  13. 13. Type => TypeFunction type
  14. 14. Function type examples•Int => String•(Int, Int) => Int•Int => Int => Int•(Int => Int) => Int
  15. 15. Scala REPL
  16. 16. Collections in Scala•Vector•Set•Map•Range
  17. 17. Functional trio•map•filter•reduce (foldLeft + foldRight)
  18. 18. Function literal
  19. 19. Function composition
  20. 20. Jacek Laskowski@JacekLaskowskihttp://blog.japila.plPitannja?

×