-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLists.ex
More file actions
42 lines (32 loc) · 788 Bytes
/
Lists.ex
File metadata and controls
42 lines (32 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
defmodule Decision do
def main do
do_stuff()
end
def do_stuff do
list1 = [1, 2, 3]
list2 = [4, 5, 6]
list3 = list1 ++ list2
list4 = list3 -- list1
IO.puts(6 in list4)
[head | tail] = list3
IO.puts("Head : #{head}")
IO.write("Tail : ")
IO.inspect(tail)
IO.inspect([97, 98], charlists: :as_lists)
Enum.each(tail, fn item ->
IO.puts(item)
end)
words = ["Random", "Words", "in a", "list"]
Enum.each(words, fn word ->
IO.puts(word)
end)
display_list(words)
IO.puts(display_list(List.delete_at(words, 1)))
IO.puts(display_list(List.insert_at(words, 4, "Yeah")))
end
def display_list([word | words]) do
IO.puts(word)
display_list(words)
end
def display_list([]), do: nil
end