MCPcopy Create free account
hub / github.com/EntilZha/PyFunctional / take

Method take

functional/pipeline.py:410–423  ·  view source on GitHub ↗

Take the first n elements of the sequence. >>> seq([1, 2, 3, 4]).take(2) [1, 2] :param n: number of elements to take :return: first n elements of sequence

(self, n)

Source from the content-addressed store, hash-verified

408 return self._transform(transformations.drop_while_t(func))
409
410 def take(self, n):
411 """
412 Take the first n elements of the sequence.
413
414 >>> seq([1, 2, 3, 4]).take(2)
415 [1, 2]
416
417 :param n: number of elements to take
418 :return: first n elements of sequence
419 """
420 if n <= 0:
421 return self._transform(transformations.take_t(0))
422 else:
423 return self._transform(transformations.take_t(n))
424
425 def take_while(self, func):
426 """

Callers 4

headMethod · 0.95
tabulateMethod · 0.95
to_listMethod · 0.80
test_takeMethod · 0.80

Calls 1

_transformMethod · 0.95

Tested by 1

test_takeMethod · 0.64