Skip to content

mapadjacent

What do you think about this?

"""
Map adjacent values in a vector.

```jldoctest
julia> mapadjacent(+, 1:5)
4-element Vector{Int64}:
 3
 5
 7
 9
```
"""
mapadjacent(f, xs) = map(splat(f), zip(xs, xs[firstindex(xs)+1:end]))

https://en.cppreference.com/w/cpp/ranges/adjacent_transform_view takes N for passing slices of size N. Maybe the julia one would be ::Val{N} or something.

Edited by jariji
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information