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

Method first

functional/pipeline.py:241–257  ·  view source on GitHub ↗

Returns the first element of the sequence. >>> seq([1, 2, 3]).first() 1 Raises IndexError when the sequence is empty. >>> seq([]).first() Traceback (most recent call last): ... IndexError: list index out of range :return:

(self)

Source from the content-addressed store, hash-verified

239 return _wrap(self.take(1)[0])
240
241 def first(self):
242 """
243 Returns the first element of the sequence.
244
245 >>> seq([1, 2, 3]).first()
246 1
247
248 Raises IndexError when the sequence is empty.
249
250 >>> seq([]).first()
251 Traceback (most recent call last):
252 ...
253 IndexError: list index out of range
254
255 :return: first element of sequence
256 """
257 return self.head()
258
259 def head_option(self):
260 """

Callers 3

productMethod · 0.95
aggregateMethod · 0.95
test_firstMethod · 0.80

Calls 1

headMethod · 0.95

Tested by 1

test_firstMethod · 0.64