Analog of `diff` operator for adjacent sum

More compact to write:

@views adjsum(a) = a[begin:end-1] + a[begin+1:end]

Using the @views macro you can opt-in to views for slices for a whole function at once.

8 Likes