diff options
Diffstat (limited to 'learn-you-some-erlang/convert.erl')
-rw-r--r-- | learn-you-some-erlang/convert.erl | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/learn-you-some-erlang/convert.erl b/learn-you-some-erlang/convert.erl new file mode 100644 index 0000000..86c3c2b --- /dev/null +++ b/learn-you-some-erlang/convert.erl @@ -0,0 +1,14 @@ +-module(convert). +-export([main/0, convert/1]). + +main() -> + [_,_] = convert({a,b}), + {_,_} = convert([a,b]), + [_,_] = convert([a,b]), + {_,_} = convert({a,b}). + +-spec convert(tuple()) -> list() + ; (list()) -> tuple(). +convert(Tup) when is_tuple(Tup) -> tuple_to_list(Tup); +convert(L = [_|_]) -> list_to_tuple(L). + |