Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Professional Scala

You're reading from   Professional Scala Combine object-oriented and functional programming to build high-performance applications

Arrow left icon
Product type Paperback
Published in Jul 2018
Publisher
ISBN-13 9781789533835
Length 186 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Ruslan Shevchenko Ruslan Shevchenko
Author Profile Icon Ruslan Shevchenko
Ruslan Shevchenko
Mads Hartmann Mads Hartmann
Author Profile Icon Mads Hartmann
Mads Hartmann
Arrow right icon
View More author details
Toc

Introduction to Functional Programming Concepts


In this section, we will cover the core concepts behind functional programming and give you the necessary knowledge to understand and write simple functional programs.

By the end of this section, you should have a good understanding of the core concepts behind functional programming, such as:

  • Writing and using pure functions

  • Using immutable classes instead of mutable classes

  • Writing and using higher-order functions

Pure Functions

At the very core of functional programming is the concept of a pure function. A function is pure if it doesn't have any side effects, that is, the function simply computes a result based on the arguments to the function and does nothing else.

Examples of side effects are modifying variables, setting fields on objects, performing input/output operations such as reading or writing a file, printing values to the console, and many more.

Let's look at some examples of both pure and impure functions to better understand...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime