Skip to content

Commit 9616574

Browse files
committed
add more typespec drills
1 parent ea70171 commit 9616574

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

exercises/typespec_drills.livemd

+31
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,23 @@ defmodule FunctionSpecs do
129129
Keyword.get(keyword_list, atom_key, "")
130130
end
131131

132+
@spec split_and_lowercase(String.t()) :: [String.t()]
133+
def split_and_lowercase(string) do
134+
string
135+
|> String.downcase()
136+
|> String.split("", trim: true)
137+
end
138+
139+
@spec string_to_int(String.t()) :: integer()
140+
def string_to_int(string) do
141+
String.to_integer(string)
142+
end
143+
144+
@spec integers_to_strings([integer()]) :: [String.t()]
145+
def integers_to_strings(integers) do
146+
Enum.map(integers, fn int -> Integer.to_string(int) end)
147+
end
148+
132149
@spec one_to_two(1) :: 2
133150
def one_to_two(1) do
134151
2
@@ -192,6 +209,20 @@ defmodule FunctionSpecs do
192209
Keyword.get(keyword_list, atom_key, "")
193210
end
194211

212+
def split_and_lowercase(string) do
213+
string
214+
|> String.downcase()
215+
|> String.split("", trim: true)
216+
end
217+
218+
def string_to_int(string) do
219+
String.to_integer(string)
220+
end
221+
222+
def integers_to_strings(integers) do
223+
Enum.map(integers, fn int -> Integer.to_string(int) end)
224+
end
225+
195226
def one_to_two(1) do
196227
2
197228
end

0 commit comments

Comments
 (0)