This document introduces functional programming with Scala. It defines functional programming as treating computation as the evaluation of mathematical functions while avoiding state and mutable data. It then discusses Scala, describing it as a modern multi-paradigm language that integrates object-oriented and functional features. The document outlines key aspects of functional programming in Scala like defining functions as values, using expressions instead of statements, function types, the Scala REPL, core collections, and functional operations like map, filter and reduce.
6. Functional programming
In computer science, functional programming
is a programming paradigm that treats
computation as the evaluation of
mathematical functions and avoids state and
mutable data. It emphasizes the application of
functions, in contrast to the imperative programming
style, which emphasizes changes in state.
HTTP://EN.WIKIPEDIA.ORG/WIKI/FUNCTIONAL_PROGRAMMING
8. Scala is a modern multi-paradigm
programming language designed to express
common programming patterns in a concise, elegant,
and type-safe way. It smoothly integrates features
of object-oriented and functional languages.
HTTP://WWW.SCALA-LANG.ORG/NODE/104
Scala is also a functional language
in the sense that every function is a
value.
9. Keyword to
define a Method
Method’s name
Method’s input
parameters and
their types
Method’s
return type
(optional)
Method’s body
10. Expression vs statement
•A statement changes state
•it’s called for side effects
•An expression produces result
FROM “ATOMIC SCALA” BY BRUCE ECKEL AND DIANNE MARSH