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

Method head

functional/pipeline.py:223–239  ·  view source on GitHub ↗

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

(self)

Source from the content-addressed store, hash-verified

221 return self
222
223 def head(self):
224 """
225 Returns the first element of the sequence.
226
227 >>> seq([1, 2, 3]).head()
228 1
229
230 Raises IndexError when the sequence is empty.
231
232 >>> seq([]).head()
233 Traceback (most recent call last):
234 ...
235 IndexError: list index out of range
236
237 :return: first element of sequence
238 """
239 return _wrap(self.take(1)[0])
240
241 def first(self):
242 """

Callers 4

firstMethod · 0.95
head_optionMethod · 0.95
test_headMethod · 0.80
test_firstMethod · 0.80

Calls 2

takeMethod · 0.95
_wrapFunction · 0.85

Tested by 2

test_headMethod · 0.64
test_firstMethod · 0.64