Example #1
0
    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)
Example #2
0
    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)
Example #3
0
 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)
Example #4
0
 def test_first(self):
     result = transduce(transducer=first(),
                        reducer=expecting_single(),
                        iterable=[2, 4, 6, 8, 10])
     self.assertEqual(result, 2)
Example #5
0
 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)
Example #6
0
 def test_first(self):
     result = transduce(transducer=first(),
                        reducer=expecting_single(),
                        iterable=[2, 4, 6, 8, 10])
     self.assertEqual(result, 2)