projects
/
python_utils.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Make config_loadfile augment cmdline instead of klobbering.
[python_utils.git]
/
list_utils.py
diff --git
a/list_utils.py
b/list_utils.py
index 9a5d4fde0dcad7936a16ffc6f53a7a50ba0b67fa..7d3355cc85a72a047aacaa0c3f06430a9e8e8dd7 100644
(file)
--- a/
list_utils.py
+++ b/
list_utils.py
@@
-15,10
+15,15
@@
def flatten(lst: List[Any]) -> List[Any]:
>>> flatten([ 1, [2, 3, 4, [5], 6], 7, [8, [9]]])
[1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> flatten([ 1, [2, 3, 4, [5], 6], 7, [8, [9]]])
[1, 2, 3, 4, 5, 6, 7, 8, 9]
-
"""
if len(lst) == 0:
return lst
if isinstance(lst[0], list):
return flatten(lst[0]) + flatten(lst[1:])
return lst[:1] + flatten(lst[1:])
"""
if len(lst) == 0:
return lst
if isinstance(lst[0], list):
return flatten(lst[0]) + flatten(lst[1:])
return lst[:1] + flatten(lst[1:])
+
+
+def prepend(item: Any, lst: List[Any]) -> List[Any]:
+ """Prepend an item to a list."""
+ lst = list.insert(0, item)
+ return lst