Cycles of a permutation: Difference between revisions

m
Line 168:
""" length of Perm """
Base.length(p::Perm) = length(p.a)
 
""" iterator interface for Perm """
Base.iterate(p::Perm, state = 1) = state > length(p) ? nothing : (p[state], state + 1)
 
""" index into a Perm """
Base.getindex(p::Perm, i::Int64) = p.a[i]
 
""" permutation signage for the Perm """
Line 197 ⟶ 191:
return Perm(a)
end
 
""" Get the Perm that functions to change one permutation result to another """
transform(p1::Perm, p2::Perm) = inv(p1) * p2
 
""" Get cycles of a Perm permutation as a vector of integer vectors, optionally with singles """
4,102

edits