I have a list of elements and I would like to create a new list by applying a function to successive overlapping pairs from the original list.
Specifically, I am trying to compute the Pythagorean sum of each pair. So, if the original list is {$a,b,c,d,...$} I want {$\sqrt{a^2+b^2},\sqrt{b^2+c^2},\sqrt{c^2+d^2},...$}
Since this is similar to the built-in Differences
function, (which turns the original list into {$b-a,c-b,d-c,...$}), I expected to find a built-in function along the lines of BuiltIn[f,{a,b,c,d,...},options]
where f
is defined by the user. But alas, my search has been fruitless...
Thanks in advance!
-----------EDIT-----------
Right after posting this, I came up with
Sqrt[#1^2 + #2^2] & @@@ Subsequences[#, {2}] &@{a, b, c, d}
which does the trick. I was going to update that here, but you all already came through with your own answers, so I'll try those as well. Thanks!