Cycles of a permutation: Difference between revisions
Content added Content deleted
m (→{{header|Julia}}: remove unused functions) |
|||
Line 230: | Line 230: | ||
""" Create a permuted string from another string using a Perm """ |
""" Create a permuted string from another string using a Perm """ |
||
permutestring(s::AbstractString, p::Perm) = String([s[i] for i in p.a]) |
permutestring(s::AbstractString, p::Perm) = String([s[i] for i in p.a]) |
||
""" Given an iterable of equal length and a Perm, return a permuted vector of the iterable's elements """ |
|||
function permuted(iterable, p1::Perm) |
|||
p2 = Perm(iterable) |
|||
inttoitem = Dict(enumerate(iterable)) |
|||
return [inttoitem(i) for i in (p1 * p2).data] |
|||
end |
|||
function testAlfBettyPerms() |
function testAlfBettyPerms() |