mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2024-11-19 06:30:29 +01:00
fix the replace! function in case length(toreplace)= 1
This commit is contained in:
parent
5a9d4b4bb6
commit
6c8591b1d4
@ -310,6 +310,19 @@ end
|
||||
|
||||
function replace!(W::GWord, index, toreplace::GWord, replacement::GWord; check=true)
|
||||
n = length(toreplace.symbols)
|
||||
if n == 0
|
||||
return reduce!(W)
|
||||
|
||||
elseif n == 1
|
||||
if check
|
||||
@assert is_subsymbol(toreplace.symbols[1], W.symbols[index])
|
||||
end
|
||||
|
||||
first = change_pow(W.symbols[index],
|
||||
W.symbols[index].pow - toreplace.symbols[1].pow)
|
||||
last = change_pow(W.symbols[index], 0)
|
||||
|
||||
else
|
||||
if check
|
||||
@assert is_subsymbol(toreplace.symbols[1], W.symbols[index])
|
||||
@assert W.symbols[index+1:index+n-2] == toreplace.symbols[2:end-1]
|
||||
@ -318,9 +331,9 @@ function replace!(W::GWord, index, toreplace::GWord, replacement::GWord; check=t
|
||||
|
||||
first = change_pow(W.symbols[index],
|
||||
W.symbols[index].pow - toreplace.symbols[1].pow)
|
||||
|
||||
last = change_pow(W.symbols[index+n-1],
|
||||
W.symbols[index+n-1].pow - toreplace.symbols[end].pow)
|
||||
end
|
||||
|
||||
replacement = first * replacement * last
|
||||
splice!(W.symbols, index:index+n-1, replacement.symbols)
|
||||
|
Loading…
Reference in New Issue
Block a user