Author Dennis Sweeney
Recipients Ananthakrishnan, Dennis Sweeney, SilentGhost, mark.dickinson, rhettinger, serhiy.storchaka, steven.daprano, tim.peters
Date 2020-02-16.20:26:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1581884810.12.0.331636760734.issue39648@roundup.psfhosted.org>
In-reply-to
Content
Correction correction: returning zero preserves the invariant below.

from math import gcd as GCD
from functools import reduce
from itertools import starmap, chain

def gcd(*args):
    return reduce(GCD, args, 0)

iterables = [[10, 20, 30],
             [],
             [0, 0, 0],
             [5],
             [-15, -10000000]]

a = gcd(*chain.from_iterable(iterables))
b = gcd(*starmap(gcd, iterables))
assert a == b == 5
History
Date User Action Args
2020-02-16 20:26:50Dennis Sweeneysetrecipients: + Dennis Sweeney, tim.peters, rhettinger, mark.dickinson, steven.daprano, SilentGhost, serhiy.storchaka, Ananthakrishnan
2020-02-16 20:26:50Dennis Sweeneysetmessageid: <1581884810.12.0.331636760734.issue39648@roundup.psfhosted.org>
2020-02-16 20:26:50Dennis Sweeneylinkissue39648 messages
2020-02-16 20:26:50Dennis Sweeneycreate