Skip to content

back to Claude Sonnet 3.5 - Fill-in summary

Claude Sonnet 3.5 - Fill-in: more-itertools

Failed to run pytests for test tests

Pytest collection failure.

Patch diff

diff --git a/more_itertools/recipes.py b/more_itertools/recipes.py
index 9c47a54..67f231c 100644
--- a/more_itertools/recipes.py
+++ b/more_itertools/recipes.py
@@ -49,7 +49,7 @@ def take(n, iterable):
         [0, 1, 2]

     """
-    pass
+    return list(islice(iterable, n))


 def tabulate(function, start=0):
@@ -67,7 +67,7 @@ def tabulate(function, start=0):
         [9, 4, 1, 0]

     """
-    pass
+    return map(function, count(start))


 def tail(n, iterable):
@@ -78,7 +78,7 @@ def tail(n, iterable):
     ['E', 'F', 'G']

     """
-    pass
+    return iter(deque(iterable, maxlen=n))


 def consume(iterator, n=None):
@@ -112,7 +112,13 @@ def consume(iterator, n=None):
         StopIteration

     """
-    pass
+    # Use functions that consume iterators at C speed.
+    if n is None:
+        # feed the entire iterator into a zero-length deque
+        deque(iterator, maxlen=0)
+    else:
+        # advance to the empty slice starting at position n
+        next(islice(iterator, n, n), None)


 def nth(iterable, n, default=None):