def test_early_terminating_transducer(self): input = [0.0, 0.2, 0.8, 0.9, 1.1, 2.3, 2.6, 3.0, 4.1] output = SingularSink() iterable_source(iterable=input, target=transduce(first(lambda x: x > 1.0), target=output())) self.assertEqual(output.value, 1.1)
def test_first_with_predicate(self): result = transduce(transducer=first(lambda x: x > 5), reducer=expecting_single(), iterable=[2, 4, 6, 8, 10]) self.assertEqual(result, 6)
def test_first(self): result = transduce(transducer=first(), reducer=expecting_single(), iterable=[2, 4, 6, 8, 10]) self.assertEqual(result, 2)