1
0
mirror of https://github.com/kalmarek/Groups.jl.git synced 2024-10-15 07:20:35 +02:00

Sort keys in subst_dict by wordlength (in reverse)

This commit is contained in:
kalmar 2017-01-26 12:50:02 +01:00
parent aa9bba617a
commit ebecf988ec

View File

@ -223,8 +223,7 @@ function replace!(W::GWord, index, toreplace::GWord, replacement::GWord; asserts
end
function replace_all!{T}(W::GWord{T}, subst_dict::Dict{GWord{T}, GWord{T}})
reduced = true
for toreplace in reverse!(sort!(collect(keys(subst_dict))))
for toreplace in reverse!(sort!(collect(keys(subst_dict)),by=length))
replacement = subst_dict[toreplace]
i = findfirst(W, toreplace)
while i 0