Erlang; list comprehension without duplicates
问题 I am doing somthing horrible but I don't know how to make it better. I am forming all pairwise sums of the elements of a List called SomeList, but I don't want to see duplicates ( I guess I want "all possible pairwise sums" ): sets:to_list(sets:from_list([A+B || A <- SomeList, B <- SomeList])) SomeList does NOT contain duplicates. This works, but is horribly inefficient, because the original list before the set conversion is GIGANTIC. Is there a better way to do this? 回答1: You could simply