Nth element of a Tuple
Vlad Dumitrescu
vlad_dumitrescu@REDACTED
Fri Apr 7 13:37:53 CEST 2006
Hi,
Replace element, or insert element? Your example does an insert...
I would like to write a function that replaces the Nth element of a
tuple.
exemple:
replace(3,{a,b,c,d},a) returns {a,b,a,c,d}
how can I do that?
Replacing is done easily with erlang:setelement(3,{a,b,c,d},a).
Inserting is not so easy, one would be to convert to a list, insert in it
and convert back to a tuple.
Regards,
Vlad
More information about the erlang-questions
mailing list