reduce!( (result, elem) => result + (elem[0]-elem[1])^^2 )(zippedRange, 0)

>
> This is really where my problem arose. I understood everything up
> to here, but I sort of had this idea, "hey zip returns a tuple so
> that somehow the compiler
> was going to figure out for me that function(e) has two values"
> and is thus
> a binary function so this should work (the 0.0 on the end was my
> start value):
>
> reduce!(function(e) { return (e[1]-e[0])*(e[1]-e[0]); })(0.0)
>
> However, of course the compiler see's the tuple as just one value
> - which is where I made my mistake.
>

The problem is not tuple, it's that reduce needs a binary function to work.

Reply via email to