Learning Functional Programming with Scala

  • Complete the Coursera course assignments, which features university level content
  • Write an application that reflects some of what I learned in this course

Why Scala?

  1. Interoperability with Java. This allows me to use my favourite libraries.
  2. I am genuinely interested in picking up more functional programming principles
  3. The job market in the Netherlands seems to need Scala developers
  4. According to StackOverflow 2020, it’s one of the highest paid languages :D
  5. In-demand + High Salary = Profit???

Week 1

Overall Syntax

Everything is an expression

Functions, Blocks & Lexical Scope

Def vs Val

Immutability

  1. Thread Safe: Immutable objects are thread safe by definition
  2. No invalid state: Once you validate the initial state of an object, you can be assured that this object always remains valid.
  3. Simpler to test: Because objects don’t change internally, they are by far easier to test, as their methods are always reproducible.

Pure Functions

  • The function must not rely on any code outside its scope, or hidden from view.
  • The function must not modify any code outside its scope.
  • The function must always evaluate to the same result, given the arguments are the same.

Recursion

  1. Implement the logic for Pascal’s Triangle
  2. Balance parentheses in a list of chars
  3. Counting the possibilities of change, given a certain list of coin types
  4. Calculate factorial

Tail Recursion

Week 2

Higher-order Functions

Currying

Functional Sets

Week 3

Traits, Generics, Classes and Objects. Huh?!

Week 4

Decomposition vs Pattern Matching

Pattern Matching List

Week 5

Huffman Encoding

Tuples

Map, Filter, Reduce

Credit: https://thenewstack.io/dont-object-ify-me-an-introduction-to-functional-programming-in-javascript/

Week 6: Scala on the Cloud

  1. The language of the file
  2. The sentence with the highest magnitude
  3. The most positive sentence
  4. The most negative sentence
  5. The general tone of the document

Used Functional Programming principles

  • The creation and decomposition of tuples
  • Higher-order functions
  • Currying
  • RegEx pattern matching
  • Nested functions
  • Awesome Scala syntax sugar. Like that cool looking ‘else-try’ block

Conclusion

Connect with me ❤

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ryan Susana

Ryan Susana

I like code, chess, reggae & hip-hop. 🇸🇽