Retrieve similar elements in two different lists in ERLANG
If you need to compare 2 lists and take the similar or different elements can be done using the following simple method. Assume two lists as X and Y.
X = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].
Y = [2, 4, 7, 20, 50, 100].
Z = X -- Y. %% Returns you the values in X and Y which are dissimilar.
X -- Z %% Returns you the values in X which are similar to values in Y.
Y -- Z %% Returns you the values in Y which are similar to values in X.
Special thanks to Sisila@Sri Lanka
Labels: compare, dissimilar elements, lists, similar elements
