Stern-Brocot sequence: Difference between revisions

→‎Python: Composing pure (curried) functions: Slightly simplified expression of the SB function.
(→‎Python: Composing pure (curried) functions: Slightly simplified expression of the SB function.)
Line 3,939:
import math
import operator
from itertools import chain, count, dropwhile, islice, takewhile
 
 
Line 3,948:
 
def go(xs):
x[a, b] = xs[1:2]
return (xa, tail(xs)[1:] + [xa + head(xs)b, xb])
return chain([1], unfoldr(go)([1, 1]))
 
 
9,659

edits