Hi all!
I believe that
sign{T<:Integer}(perm::AbstractVector{T})
is already defined and returns something like
[sign(n) for n in perm]
So, I think it would be better to call it by other name, or with a
different signature.
By looking at the code at the code used in Permutations, I came up with two
solutions that should run in O(n) time. They are optimized versions of
Permutations.parity and can be found here:
https://gist.github.com/pabloferz/01675f1bf4c8be359767#file-levicivita-jl
The second option, is almost the same as the first one, but instead of
first checking if the Vector is a permutation at the begining, it does the
check in-place. There's probably not much difference between the two, I
have not analyzed this deeper. Anyway, I believe both should work fine.
Cheers!