Created
August 4, 2010 10:20
-
-
Save pelletier/507940 to your computer and use it in GitHub Desktop.
I know this function already exists, but here is my idea of implementation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Converts a tuple to a list. | |
% {a, b, c, d} -> [a, b, c, d] | |
tuple_to_list(T) -> | |
tuple_to_list(T, 0). | |
tuple_to_list(_T, -1) -> | |
[]; | |
tuple_to_list(T, Id) -> | |
Max = tuple_size(T) - 1, | |
E = if | |
Id > Max -> | |
Nid = -1, | |
[]; | |
true -> | |
Nid = Id +1, | |
[element(T, Id)] | |
end, | |
lists:append(E, tuple_to_list(T, Nid)). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment