Say i have two lists: AmountOfProducts which has a list of tuples like
[{apple, 10}, {chocolate, 13}, {lettuce, 9}, {mango, 20}]
And the second list is the OrderProducts which has tuples like
[{apple, 3}, {chocolate, 1}, {mango 4}]
The first element is the atom for the name of the product, the second element is the amount, for AmountOfProducts the amount is the number available and for OrderProducts its the amount its asking for. Is there a way to check if the all atoms of OrderProducts exists inside AmountOfProducts and return a true? And if, lets say OrderProducts had an extra tuple and its atom didnt exist inside AmountOfProducts for it to return false? The idea is something like this:
AmountOfProducts = [{apple, 10}, {chocolate, 13}, {lettuce, 9}, {mango, 20}]
OrderProducts = [{apple, 3}, {chocolate, 1}, {mango 4}]
check_products(AmountOfProducts, OrderProducts) ->
if
all atoms inside OrderProducts exists in AmountOfProducts -> true;
one or many of the atoms inside OrderProducts doesnt exist in AmountOfProducts -> false
end.
In the given case of the two lists it should come back as true. Is there a way to do this? I hope this makes sense, Thanks!