Move the lists:reverse() in make_chains() to preserve input's order in the output

This commit is contained in:
Scott Lystig Fritchie 2014-02-20 19:16:39 +09:00
parent e791876212
commit d2562588f2

View file

@ -566,7 +566,7 @@ make_chains(ChainLen, FLUs) ->
make_chains(ChainLen, FLUs, [], []).
make_chains(_ChainLen, [], SmallAcc, BigAcc) ->
lists:reverse([SmallAcc|BigAcc]);
[lists:reverse(SmallAcc)|BigAcc];
make_chains(ChainLen, [H|T], SmallAcc, BigAcc) ->
if length(SmallAcc) == ChainLen ->
make_chains(ChainLen, T, [H], [SmallAcc|BigAcc]);