Jacobsthal numbers: Difference between revisions

Content added Content deleted
Line 1,319: Line 1,319:
'''Infinite sequence of terms of OEIS A001045
'''Infinite sequence of terms of OEIS A001045
'''
'''
return jacobsthalish(0, 1)
return jacobsthalish([0, 1])




# jacobsthalish :: (Int, Int) -> [Int]
# jacobsthalish :: (Int, Int) -> [Int]
def jacobsthalish(a, b):
def jacobsthalish(xs):
'''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(ys):
a, *t = xs
a, *t = ys
return a, t + [2 * a + t[0]]
return a, t + [2 * a + t[0]]


return unfoldr(go)([a, b])
return unfoldr(go)(xs)




Line 1,347: Line 1,347:
(
(
'Jacobsthal-Lucas numbers',
'Jacobsthal-Lucas numbers',
30, jacobsthalish(2, 1)
30, jacobsthalish([2, 1])
),
),
(
(