elixir KERNEL 2 Flashcards

(54 cards)

1
Q

is_map(%{})

A

=> true

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

What type of Error raised when executing? not nil

A

ArgumentError

*Note: Arguments must be a boolean

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

length([a: 1, b: 2])

A

=> 2

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

hd([5, 6, 7])

A

=> 5

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

is_float(1.2)

A

=> true

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

What type of Error raised when executing?

elem({}, 0)

A

ArgumentError

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

is_map(%Range{})

A

=> true

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

true and “hello”

A

=> “hello”

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

is_nil(nil)

A

=> true

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

to_string(12.3)

A

=> “12.3”

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

false and “hello”

A

=> false

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

rem(8, -7)

A

=> 1

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

elem({1, 2, :hello}, 1)

A

=> 2

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

apply(Kernel, :byte_size, [“cat”])

A

=> 3

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

is_function(fn(x) -> x + 1 end)

A

=> true

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

is_integer(28) == is_number(2.7)

A

=> true

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

tuple = {:clever, “bunny”}

put_elem(tuple, 0, “funny”)

A

=> {“funny”, “bunny”}

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

inspect(:hello)

A

=> “:hello”

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

byte_size(«1, 2»)

A

=> 2

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

inspect(‘bar’)

A

=> “‘bar’”

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

not false

A

=> true

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

inspect [1, 2, 3], limit: 2

A

=> “[1, 2, …]”

23
Q

self() |> is_pid()

24
Q

iex> x = 1

iex> binding()

A

iex => [x: 1]

*Note: Returns the binding for the given context as a keyword list

25
is_list([])
=> true
26
to_string([1, 2, 3])
=> <<1, 2, 3>>
27
true or false
=> true
28
inspect(15, base: :hex)
=> "OxF"
29
What type of Error raised when executing? | :hello or true
** (BadBooleanError) expected a boolean on left-side of "or", got: :hello
30
to_string(:hello)
=> "hello"
31
map_size(%{a: 1})
=> 1
32
to_string(123)
=> "123"
33
max(1, :a)
=> :a | *Note: term ordering: number < atom < reference < function < port < pid < tuple < map < list < bitstring
34
round(4.49)
=> 4
35
node() |> is_binary()
=> false *Note: Returns an atom representing the name of the local node. If the node is not alive, :nonode@nohost is returned instead
36
What type of error would be raised when evaluating? | 1 and true
** (BadBooleanError) expected a boolean on left-side of "and", got: 1
37
iex> x = 1 iex> x = 2 iex> binding()
=> [x: 2] *Note: Returns the binding for the given context as a keyword list.
38
What type of error is raised when executing? | rem(8, 0.8)
** (ArithmeticError) bad argument in arithmetic expression | :erlang.rem(8, 0.8)
39
1 && 4 == 1 and 4
=> false | *Note: and accepts boolean as a first argument. && accepts any expression as the first argument
40
fun = fn x -> max(x, 3) end | apply(fun, [2])
=> 3
41
Agent.start(fn() -> [] end) |> is_tuple()
=> true | *Returns {:ok, #PID}
42
make_ref() |> is_reference()
=> true
43
``` if is_bitstring("bunny") do "bunny is a bitstring" else "not a bitstring" end ```
=> "bunny is a bitstring"
44
min(self(), :hello)
=> :hello | *Note: term ordering: number < atom < reference < function < port < pid < tuple < map < list < bitstring
45
if div(8, 2) == 3, do: "yes"
=> nil | *Note nil is returned when condition passed to if doesn't return true
46
What type of Error raised when executing? | to_string({:ok, "hello"})
** (Protocol.UndefinedError) | protocol String.Chars not implemented for {:ok, "hello"} of type Tuple
47
inspect( "hello" <> <<0>>, binaries: :as_strings )
=> "\"hello\\0\""
48
inspect( "h" <> <<0>>, binaries: :as_binaries )
=> "<<104, 0>>"
49
iex> x = 1 iex> y = 2 iex> binding()
=> [x: 1, y: 2] | *Note: Returns the binding for the given context as a keyword list.
50
What type of Error is raised when executing? | hd([])
ArgumentError
51
true and 4 and 5
** (BadBooleanError) expected a boolean on left-side of "and", got: 4
52
byte_size(<<145::24, 5::4>>)
=> 4 *Note: if the number of bits in bitstring is not divisible by 8, the resulting number of bytes will be rounded up (by excess)
53
is_function(fn(x) -> x + 1 end, 2)
=> false | *Note: Returns true if term is a function that can be applied with arity number of arguments; otherwise returns false
54
true or "hello"
=> true *Note: If the first argument is true, true is returned; otherwise, the second argument is returned. Requires only the first argument to be a boolean since it short-circuits.