On 3 May 2016 at 05:19, Rob Stewart
On May 2, 2016 5:30:40 AM EDT, Jeremy Murphy < jeremy.william.murphy@gmail.com> wrote:
A variadic template version with the same name makes sense to me, though.
There's some detail missing. How is your iterated GCD function different from a variadic gcd()?
Only in the type signature. It's fairly obvious but I'll make it explicit. Variadic gcd takes n things of type T and returns a T: f(T, ..., T) -> T whereas "iterated" gcd takes a thing (Range) or things (iterators) that denote a range of Ts: g(U) -> T g(U, U) -> T So yes, in the implementation, variadic gcd is an iterated binary operation (with special case of n=1). But the semantics are different because of how the input is interpreted, which for me is sufficient reason to give them different names. So it's probably more accurate that I say it's gcd over an iterator range that I think should have a different name to 'plain' gcd (which is iterated in a variadic version). Which makes the "_range" suffix all the more sensible. Cheers. Jeremy