Erlang Flashcards

1
Q

Erlang vs Clojure

A

Like:
-Erlang is a functional language like Clojure
-no type declarations
Unlike:
-It is not a direct mapping of the LISP language

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

How is it similar to Java?

A

-Runs on top of a virtual machine(BEAM)
-Can support other languages that run on its VM

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

What are the 2 ways Erlang can be run?

A

1.An interactive command line shell called Eshell
2.By compiling the code and running it directly with erl.

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

Erlang uses several separators to differ expressions from each other. What are they?

A

1.Commas: used between function arguments and between expression in function body.
2.Semi-colons: used between alternate forms or arities if a function.
3.Period: used to terminate a complete expression

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

What are the 3 simple types?

A

Integers
Floating point values
Strings: surrounded by double quotes
*No boolean

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

What are the 4 main composite data structures?

A

Tuple
List
Record
Map

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

Describe tuples

A

-Written using curly braces with elements separated by commas
-No labels associated with a tuple
-“atom” is used as the first element of a type (begins w lowercase letter)

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

How does Erlang use pattern matching ?

A

– Comments in Erlang use the % character
– Erlang uses pattern matching to map the fields of P (right hand side or RHS) to the elements on the left hand side (LHS)
– An error (no match of right hand side) will be generated if the match is not valid.
– Finally, we can use an underscore “_” when we do not need to save a particular field.

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

Describe lists

A

-Written with square brackets with each element separated by commas
-Lists can contain any other types/structures and can be of arbitrary length. SAME AS LISP
-Erlang considers lists to consist of a Head and a Tail (he head is the first element, the tail is everything else)

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

Describe records

A

-Written with curly brackets
-They’re like tuples but we can associate labels with values.
-Different than other types because they have an actual declaration.
-Define only ONCE
-Name and keys must be atoms
-Generally declared separately and then included in the current file

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