Data Types Flashcards

1
Q

What data type should you use if order is important

A

Lists

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

What are maps O notation for random access?

A

O(log n)

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

What are lists’ random access O notation

A

O(n)

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

If you need to work w/ individual characters in a list, what data type should you use?

A

charlist

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

what kind of quotes do charlists use?

A

single

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

why should processes not hold long strings?

A

It’s an optimization. Long strings are shared across processes, but this optimization can lead to memory leaks.

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

What’s the O notation for finding a character in a sring?

A

O(n), just like lists

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

Explain drawbacks of String concatenation.

A

It’s slow, there’s a trick for doing it that Phoenix uses for templates. See page 31 of Designing Elixir Systems for how to use IO lists to do more perofmant string concatenations

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

When is the use of tuples preffered?

A

when the order means something, like in x, y co-ordinates

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

If you’re editing tuples a lot, what data structure should you switch too?

A

maps

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

What is the fastest Elixir data structure for random access?

A

tuples

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

Why is it good to send the function to the data rather than the data to a function?

A

Multiple processes may be running. Sending data from one process to another often means that each process needs a copy of the data which is wasteful. Also, it means potentially sending more data over the network if the processes are running on different machines. This makes sending the function faster as less data needs to be copied and/or sent over a given netowrk.

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

Should you prefer flat or deep data structures?

A

flat

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

Define the “functional core”

A

a group of functions and the type definitions representing the data layer, organized into modules

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