コード例 #1
0
ファイル: tests.py プロジェクト: Gizmo707/fn.py
 def test_unfold_finite(self):
     countdown = op.unfold(lambda x: (x-1, x-2) if x > 1 else None)
     self.assertEqual([9,7,5,3,1], list(countdown(10)))
コード例 #2
0
ファイル: tests.py プロジェクト: pawroman/fn.py
 def test_unfold_finite(self):
     countdown = op.unfold(lambda x: (x - 1, x - 2) if x > 1 else None)
     self.assertEqual([9, 7, 5, 3, 1], list(countdown(10)))
コード例 #3
0
ファイル: tests.py プロジェクト: Gizmo707/fn.py
 def test_unfold_infinite(self):
     doubler = op.unfold(lambda x: (x*2, x*2))
     self.assertEqual(20, next(doubler(10)))
     self.assertEqual([20, 40, 80, 160, 320], list(iters.take(5, doubler(10))))
コード例 #4
0
ファイル: tests.py プロジェクト: pawroman/fn.py
 def test_unfold_infinite(self):
     doubler = op.unfold(lambda x: (x * 2, x * 2))
     self.assertEqual(20, next(doubler(10)))
     self.assertEqual([20, 40, 80, 160, 320],
                      list(iters.take(5, doubler(10))))