projects
/
python_utils.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Workaround likely client bug in letter_compress. Update tests in bst.
[python_utils.git]
/
list_utils.py
diff --git
a/list_utils.py
b/list_utils.py
index c04a5343be656b62a07fc0d6af8b9b9880b5feda..182e2bc5c104908f39a15e4675021e6ed8a7c338 100644
(file)
--- a/
list_utils.py
+++ b/
list_utils.py
@@
-2,7
+2,7
@@
from collections import Counter
from itertools import islice
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]:
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))
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()
if __name__ == '__main__':
import doctest
doctest.testmod()