Jacobsthal numbers: Difference between revisions

Content added Content deleted
Line 1,322: Line 1,322:


# jacobsthalish :: (Int, Int) -> [Int]
# jacobsthalish :: (Int, Int) -> [Int]
def jacobsthalish(ab):
def jacobsthalish(xy):
'''Infinite sequence of jacobsthal-type series
'''Infinite sequence of jacobsthal-type series
beginning with a, b
beginning with a, b
'''
'''
def go(xs):
def go(ab):
a, *t = xs
a, b = ab
return a, t + [2 * a + t[0]]
return a, [b, 2 * a + b]


return unfoldr(go)(list(ab))
return unfoldr(go)(xy)