other stuff Flashcards

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
Q

x.flatMap(f)

A

collection obtained from applying the collection-valued function f to every element in x and concatenating the results

26
Q

xs.foldLeft(z)(op)

A

Apply binary operation op between successive elements of xs, going left to right and starting with z

27
Q

xs.foldRight(z)(op)

A

Apply binary operation op between successive elements of xs, going right to left and starting with z.

28
Q

monoid

A

a set and an associated binary oeprator that combines two elements from the set
def[A] |+| (left: A, right: A): A

29
Q

zipWithIndex

A

return a set of tuples (element, index)

30
Q

Nothing

A

has no values
is a subtype of everyhing

31
Q

Linear pattern

A

each variable occurs only once

32
Q

Sealed classes

A

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
Q

Option

A

be either Some[T] or None object, which represents a missing value

34
Q

Tail Recursion

A

he recursive call is the last thing done by the function

35
Q

Static typing

A

check types at compile time, without running the code

36
Q

Dynamic typing

A

check types at runtime, while running the code

37
Q

:<
A :< B

A

specifies an upper bound
B is upper bound of A

38
Q

traits

A

like an abstract class
a class can extend multiple traits (but one class)
a trait also defines a type

39
Q

Diamond problem

A

occurs whenever we have some type of multiple inheritance

40
Q

Linearisation

A
  • Searched in linear order for method implementation:
    Deepest first, last trait first
41
Q

COVARIANCE
If A:B =>

A

COVARIANCE
→ more specific output
=> then I<a> : I<b></b></a>

(if A is a subtype of B)

42
Q

CONTRAVARIANCE
If A:B then =>

A

→ more general input

=> I<b> : I<a></a></b>

43
Q

INVARIANCE

A

input and output

44
Q

variance of:
lists
arrays
seq

A

covariant
contravariant
covariant

45
Q

function subtyping
A ⇒ B

A

functions are contravariant in their arguments but covariant in their results
general ⇒ specific

46
Q
A