Skip to content

Commit 2a79f41

Browse files
committed
resolve elixir language-list
1 parent 781fbaa commit 2a79f41

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
11
defmodule LanguageList do
2+
@spec new :: []
23
def new() do
3-
# Please implement the new/0 function
4+
[]
45
end
56

7+
@spec add(nonempty_maybe_improper_list, any) :: nonempty_maybe_improper_list
68
def add(list, language) do
7-
# Please implement the add/2 function
9+
[language | list]
810
end
911

10-
def remove(list) do
11-
# Please implement the remove/1 function
12+
@spec remove(nonempty_maybe_improper_list) :: any
13+
def remove([_ | t]) do
14+
t
1215
end
1316

14-
def first(list) do
15-
# Please implement the first/1 function
17+
@spec first(nonempty_maybe_improper_list) :: any
18+
def first([h | _]) do
19+
h
1620
end
1721

22+
@spec count(list) :: non_neg_integer
1823
def count(list) do
19-
# Please implement the count/1 function
24+
length list
2025
end
2126

27+
@spec functional_list?(any) :: boolean
2228
def functional_list?(list) do
23-
# Please implement the functional_list?/1 function
29+
"Elixir" in list
2430
end
2531
end

0 commit comments

Comments
 (0)