1
0
mirror of https://github.com/kalmarek/Groups.jl.git synced 2024-11-19 06:30:29 +01:00

add replace and replace_all functions

This commit is contained in:
kalmar 2017-01-26 12:50:54 +01:00
parent ebecf988ec
commit 986dc7748f

View File

@ -222,6 +222,10 @@ function replace!(W::GWord, index, toreplace::GWord, replacement::GWord; asserts
return W
end
function replace(W::GWord, index, toreplace::GWord, replacement::GWord)
replace!(deepcopy(W), index, toreplace, replacement)
end
function replace_all!{T}(W::GWord{T}, subst_dict::Dict{GWord{T}, GWord{T}})
for toreplace in reverse!(sort!(collect(keys(subst_dict)),by=length))
replacement = subst_dict[toreplace]
@ -234,6 +238,8 @@ function replace_all!{T}(W::GWord{T}, subst_dict::Dict{GWord{T}, GWord{T}})
return W
end
replace_all(W::GWord, subst_dict::Dict{GWord, GWord}) = replace_all!(deepcopy(W), subst_dict)
include("free_groups.jl")
include("automorphism_groups.jl")