I found a number of solutions of Rosetta problem at Yet Another Rosetta Code Problem (Perl, Ruby, Python, Haskell), but didn’t see any solution in Erlang, so here it is:
-module(rosetta). -compile(export_all). test() -> rosetta("ZYEEEEEABBCCCDDDDF"). rosetta(L) -> lists:reverse(lists:foldl(fun rosetta/2, [], L)). rosetta(H, [[H|T]|TT]) -> [[H,H|T]|TT]; rosetta(H, L) -> [[H]|L].