Is there any way to find unique values between two lists without using a loop?
List<String> first = ['A','B','C','D'];
List<String> second = ['B','D'];
I need the result to be like this:
result = ['A','C'];
here == operator the instance of the list not the content, where are equals method compare the data inside lists. List<String>list3=list1; print(list1==list3);
To quickly select the unique or distinct list including column headers, filter unique values, click on any cell in the unique list, and then press Ctrl + A. To select distinct or unique values without column headers, filter unique values, select the first cell with data,...
Find unique values in a column To find distinct or unique values in a list, use one of the following formulas, where A2 is the first and A10 is the last cell with data. How to find unique values in Excel: =IF (COUNTIF ($A$2:$A$10, $A2)=1, "Unique", "")
Formula to find distinct rows: If you are working with a data set where case matters, you'd need a bit more trickier array formula. Finding case-sensitive unique values: Finding case-sensitive distinct values: Since both are array formulas, be sure to press Ctrl + Shift + Enter to complete them correctly.
Unique values are the items that appear in a dataset only once. Distinct values are all different items in a list, i.e. unique values and 1 st occurrences of duplicate values. And now, let's investigate the most efficient techniques to deal with unique and distinct values in your Excel sheets.
You can use where()
with contains()
methods from List
:
void main() {
List<String> first = ['A','B','C','D'];
List<String> second = ['B','D'];
List<String> result = first.where((item) => !second.contains(item)).toList();
print(result); // [A, C]
}
Edit in DartPad.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With