other stuff Flashcards

(46 cards)

1
Q

Curried function form

A

A ⇒ (B ⇒ C) = (A)(B) ⇒ C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Uncurried function form

A

(A,B) ⇒ C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

First-class functions

A

treated like any other value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

lazy val

A

computed once, when value is first used, reuses value afterwards

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

def

A

computed each time when value is used

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

val

A

computed once, when object is created, reuses value afterwards

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

closure

A

has free parameters ( which can be modified inside it)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

generic classes

A

take types as a parameter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

abstract

A

needs to be extended
Cannot instantiateabstract classes directly
Abstract methodsmust be implemented by subclasses
Supportspolymorphismand code reuse through inheritance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

null

A

a subtype of any (+user defined) class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

final

A

cannot be overridden or redefined in subclasses
No subclasses possible

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

super

A

use super keyword to call the immediate parent class’ method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

any

A

Every class in a Scala execution environment inherits directly or indirectly from this class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Overloading

A

ability to redefine a function in more than one form, by defining two or more functions in a class sharing the same name
sum(a,b,c) <-> sum(a,b)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

LUB

A

the lowest common ancestor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

exists
x.exists(p)

A

a boolean indicating whether the predicate p holds for some element in x

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

forall
x.forall(p)

A

a boolean indicating whether the predicate p holds for all elements of x

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

count
x.count(p)

A

the number of elements in x that satisfy the predicate p

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

takewhile
x.takeWhile(p)

A

The longest prefix of elements in the collection that all satisfy p

20
Q

dropwhile
x.dropWhile(p)

A

The collection without the longest prefix of elements that all satisfy p

21
Q

x.foreach(f)

A

executes function f for each element of x

22
Q

x.map(f)

A

the collection obtained from applying the function f to every element in x

23
Q

desugaring
loop ->
yield ->
yield with multiple indices ->

A

foreach
map, filter
flatmap

24
Q

x.filter(p)

A

collection consisting of those elements of x that satisfy the predicate p

25
x.flatMap(f)
collection obtained from applying the collection-valued function f to every element in x and concatenating the results
26
xs.foldLeft(z)(op)
Apply binary operation op between successive elements of xs, going left to right and starting with z
27
xs.foldRight(z)(op)
Apply binary operation op between successive elements of xs, going right to left and starting with z.
28
monoid
a set and an associated binary oeprator that combines two elements from the set def[A] |+| (left: A, right: A): A
29
zipWithIndex
return a set of tuples (element, index)
30
Nothing
has no values is a subtype of everyhing
31
Linear pattern
each variable occurs only once
32
Sealed classes
No extension of the class is possible outside of the current file If a function is not sealed, it needs a default case or you will get a warning: match is not exhaustive! -> allows exhaustive pattern matching
33
Option
be either Some[T] or None object, which represents a missing value
34
Tail Recursion
he recursive call is the last thing done by the function
35
Static typing
check types at compile time, without running the code
36
Dynamic typing
check types at runtime, while running the code
37
:< A :< B
specifies an upper bound B is upper bound of A
38
traits
like an abstract class a class can extend multiple traits (but one class) a trait also defines a type
39
Diamond problem
occurs whenever we have some type of multiple inheritance
40
Linearisation
- Searched in linear order for method implementation: Deepest first, last trait first
41
COVARIANCE If A:B =>
COVARIANCE → more specific output => then I : I (if A is a subtype of B)
43
INVARIANCE
input and output
44
variance of: lists arrays seq
covariant contravariant covariant
45
function subtyping A ⇒ B
functions are contravariant in their arguments but covariant in their results general ⇒ specific
46