diff --git a/src/Groups.jl b/src/Groups.jl index 2d0aae2..dfb027e 100644 --- a/src/Groups.jl +++ b/src/Groups.jl @@ -365,7 +365,12 @@ function replace_all!{T}(W::GWord{T}, subst_dict::Dict{GWord{T}, GWord{T}}) return modified end -replace_all{T<:GSymbol}(W::GWord{T}, subst_dict::Dict{GWord{T}, GWord{T}}) = replace_all!(deepcopy(W), subst_dict) +function replace_all{T<:GSymbol}(W::GWord{T}, + subst_dict::Dict{GWord{T}, GWord{T}}) + W = deepcopy(W) + replace_all!(W, subst_dict) + return W +end ############################################################################### # diff --git a/test/FreeGroup-tests.jl b/test/FreeGroup-tests.jl index a193471..698dc38 100644 --- a/test/FreeGroup-tests.jl +++ b/test/FreeGroup-tests.jl @@ -131,7 +131,7 @@ end @test Groups.replace(c, 1, w, subst[w]) == s*t^-1 @test Groups.replace(s*c*t^-1, 1, w, subst[w]) == s^2*t^-2 @test Groups.replace(t*c*t, 2, w, subst[w]) == t*s - @test Groups.replace_all!(s*c*s*c*s, subst) == s*t^4*s*t^4*s + @test Groups.replace_all(s*c*s*c*s, subst) == s*t^4*s*t^4*s G = FreeGroup(["x", "y"]) x,y = Nemo.gens(G)