nub package:foldl

O(n log n). Fold values into a list with duplicates removed, while preserving their first occurrences
O(n^2). Fold values into a list with duplicates removed, while preserving their first occurrences