-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inverse of circshift(_, shifts)
#49
Comments
Hm, that's quite specialized - what do you think @devmotion ? |
For example, suppose you have a list of items using Accessors, AccessorsExtra
julia> x = collect(1:5)
5-element Vector{Int64}:
1
2
3
4
5
julia> @modify(x |> view(_, 2:4)) do y
circshift(y, -2)
end
5-element Vector{Int64}:
1
4
2
3
5 Suppose you want to put julia> using Accessors, InverseFunctions
julia> InverseFunctions.inverse(f::Base.Fix2{typeof(circshift)}) = Base.Fix2(circshift, -f.x);
julia> x = [5,6,7,8,9];
julia> modify(x, @o circshift(_, 3)) do y
append!(y, 10:10:20)
end
7-element Vector{Int64}:
5
6
10
20
7
8
9 |
Sure, it's definitely useful. The only thing is, we don't really have |
Nice. Is there one for
too? |
@jariji, do have have any example use cases in mind? |
Those were the examples I had, but there might be better ones. I'll see what else I can come up with. |
Thanks - it's just that if we defines inverses also for functions with fixed arguments (beyond some basic math functions like we do now) then there might be a lot of functions in Base that could qualify, but most of them will not really come up in use cases for |
I think the inverse of
circshift(_, shifts)
iscircshift(_, map(-, shifts))
. Would that fit here?The text was updated successfully, but these errors were encountered: