Cycles of a permutation: Difference between revisions

Content added Content deleted
Line 168: Line 168:
""" length of Perm """
""" length of Perm """
Base.length(p::Perm) = length(p.a)
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 """
""" permutation signage for the Perm """
Line 197: Line 191:
return Perm(a)
return Perm(a)
end
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 """
""" Get cycles of a Perm permutation as a vector of integer vectors, optionally with singles """