Workaround likely client bug in letter_compress. Update tests in bst.
[python_utils.git] / list_utils.py
index c04a5343be656b62a07fc0d6af8b9b9880b5feda..182e2bc5c104908f39a15e4675021e6ed8a7c338 100644 (file)
@@ -2,7 +2,7 @@
 
 from collections import Counter
 from itertools import islice
-from typing import Any, Iterator, List, Mapping
+from typing import Any, Iterator, List, Mapping, Sequence
 
 
 def shard(lst: List[Any], size: int) -> Iterator[Any]:
@@ -97,6 +97,19 @@ def dedup_list(lst: List[Any]) -> List[Any]:
     return list(set(lst))
 
 
+def uniq(lst: List[Any]) -> List[Any]:
+    """
+    Alias for dedup_list.
+
+    """
+    return dedup_list(lst)
+
+
+def ngrams(lst: Sequence[Any], n):
+    for i in range(len(lst) - n + 1):
+        yield lst[i:i + n]
+
+
 if __name__ == '__main__':
     import doctest
     doctest.testmod()