Explore tens of thousands of sets crafted by our community.
Scala Functional Programming
28
Flashcards
0/28
Macros
Macros in Scala are powerful language features allowing compile-time code transformations and generation, usually used for metaprogramming.
Immutable Values (val)
In Scala, 'val' is used to declare a variable that is immutable, meaning its value cannot be changed once assigned.
Higher-Order Functions
Higher-order functions are functions that can take other functions as parameters and/or return a function as a result.
Pattern Matching
Pattern matching is a mechanism for checking a value against a pattern and deconstructing complex data structures.
Case Classes
Case classes are special types of classes in Scala useful in pattern matching, automatically providing functionality like equality, serialization, and hashCode.
Closures
A closure is a function that captures the bindings of free variables in its lexical context.
Option Type
The Option type in Scala is used to represent optional values that could either be something (Some) or nothing (None), providing a safer alternative to null.
Functional Composition
Functional composition is the act of combining simple functions to build more complex functions.
Immutable Collections
Immutable collections in Scala do not allow modification of their elements once created. They can be found in the 'scala.collection.immutable' package.
Streams
Streams in Scala are lazy lists where elements are computed on-demand. Useful for representing infinite sequences.
Partial Functions
Partial functions are functions that are only defined for certain values of their input type. They are represented in Scala using 'PartialFunction' type.
Type Classes
Type classes are a pattern that allow us to extend existing classes with new behavior, without using inheritance or altering the class itself.
Implicit Conversions
Implicit conversions allow automatic conversion between compatible types, using functions marked with the 'implicit' keyword.
First-Class Functions
First-class functions are treated as first-class citizens, meaning they can be assigned to variables, passed as arguments, and returned from other functions.
Lazy Evaluation
Lazy evaluation delays the evaluation of an expression until its value is needed, potentially reducing computing overhead.
For-Comprehensions
For-comprehensions in Scala provide a clearer syntax for composing multiple operations with monads, including Options, Try, Lists, etc.
Continuations
Continuations represent points in a program where execution can continue. Scala offers a mechanism to capture continuations with a library support.
Monads
A monad is a design pattern used to handle program control flow in a functional way, allowing for sequential operations.
Partial Function Application
Partial function application refers to the process of fixing a number of arguments to a function, producing another function of smaller arity.
Try and Either Types
The Try and Either types are used to represent computations that might result in a failure. Try has Success and Failure cases, while Either has Left and Right (by convention, Right is successful).
View
A view in Scala provides a lazy version of a collection, where transformations will not be applied until they are explicitly forced or an element is accessed.
Parallel Collections
Parallel collections in Scala allow for easy parallelization of operations over a collection, utilizing multi-core architecture effectively.
Algebraic Data Types (ADTs)
ADTs are a kind of composite type used in functional programming, consisting of product types (e.g., case classes) and sum types (e.g., sealed trait hierarchies).
Type Inference
Scala's type inference system allows the language to deduce types automatically, reducing the amount of type annotations needed by the programmer.
Value Discarding
Value discarding occurs when the result of an expression is not used, often due to the side effects the expression performs.
Tail Recursion
Tail recursion is a specific form of recursion where the recursive call is the last operation in the function, allowing for optimization by the compiler.
Currying
Currying is the technique of transforming a function with multiple arguments into a sequence of functions, each with a single argument.
Pure Functions
A pure function is a function where the return value is determined solely by its input values, without observable side effects.
© Hypatia.Tech. 2024 All rights reserved.