Elixir Flashcards

1
Q

terminal line for the console?

A

iex

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

Framework used with Elixir?

A

Phoenix

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

Which virtual machine do Elixir programs compile to?

A

Erlang

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

How do Erlang and Elixir work together?

A

The Erlang VM runs as one operating system process, and by default runs one OS thread per core. Elixir programs use all CPU cores.

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

Why is Erlang faster than other platforms?

A

Erlang is faster than other platforms because it doesn’t allow mutability or shared memory by default.

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

Erlang is a _____ programming language.

A

functional

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

How does functional programming treat computation?

A

As the evaluation of functions, and avoids mutable state and data. immutable data structures and single assignment variables

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

Main difference between Obeject & Functional Programming?

A

Object doesn’t enforce isolated state. Values can be mutated in place. Functional has immutable data structures and single assignment variables

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

What is the Elixir match operator?

A

the = operator is the match operator. It enables us to assign and then match values

iex> {a, b, 42} = {:hello, “world”, 42}

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

What is Mix and what does it do?

A

it’s an Elixir development tool

Creates projects

Compiles projects

Runs ‘tasks’ (i.e running tests or generating documentation)

Manages dependencies

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

What is the CL for generating new Elixir project?

A

mix new name-of-project

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

How is code organized in Elixir?

A

In modules. A collection of different methods or functions.

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

CL to compile and run your project in the Elixir console?

A

iex -S mix

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

What is CL to access the Elixir console?

A

iex = interactive Elixir shell

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

How do you call a method on a module?

A

with .

you can use or leave out the parentheses

Cards.hello
Cards.hello()

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

Which is convention? single or double quotes

A

double quotes

17
Q

console CL for refreshing your console with updated code?

A

recompile

18
Q

Main diff between object and functional programming?

A

With functional, you can’t create classes or copies or instances of a class. It’s just a collection of methods in a module. You pass in data and the module applies a method to that data.

But you do have assignment variables

19
Q

Term for number of arguments a method accepts?

A

arity

Method as an ‘arity’ of 1 (argument)

20
Q

How does Elixir handle variables?

A

Variables are immutable. We never modify any existing data. We create and return a new one/copy.

21
Q

Syntax for a “for” loop?

A

for element

22
Q

Syntax for string interpolation?

A

{ }

23
Q

What does a nested for loop produce?

A

nested lists/arrays

24
Q

Method to check if a list contains a particular element?

A

Enum.member?(list, element)

25
Q

What is a tuple?

A

Like an array where each index has a special meaning.

Uses { }

26
Q

Method to randomly separate a list by a given value?

A

Enum.split(list, num)

returns a tuple with two lists. separated list at index 0, rest of the list at index 1)

27
Q

How is Erlang code identified?

A

with a colon :

28
Q

How do Elixir and Erlang work together?

A

Elixir sits on top of Erland and we can call Erlang code at any time.

29
Q

Elixir version of an if statemement?

A

case variable do
:ok -> code
:error -> code
end

30
Q

What are atoms?

A

premitive variables to handle status and control flows. similar to strings, but an atom is codified.

:ok
:error

31
Q

What does _variable mean in pattern matching?

A

We know there is going to be an element there in the pattern match, but we don’t want to use it (but we still have to put it in for the purpose of pattern matching)