Checks if a list is a subset of another list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///A function that checks if a list is a subset of another | |
bool subsetChecker(List list1, List list2) { | |
//Iterates through first array and checks if all element are in second array | |
return list1.every((item) => list2.contains(item)); | |
} | |
void main() { | |
print(subsetChecker([1,2,3], [1,2,4,3,5])); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment