Update word.rb

This commit is contained in:
Deepi Garg 2020-03-28 22:49:34 +05:30 committed by GitHub
parent 9e0eca64e8
commit aae168fe13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 24 deletions

View File

@ -191,30 +191,30 @@ module Parfait
end
def insert(index, other)
if index<0
index = length+1+index
end
cpy = Word.new( length+other.length )
cpy_ind=0
str_ind=0
while ( str_ind<index )
cpy.set_char(cpy_ind,get_char(str_ind))
cpy_ind=cpy_ind+1
str_ind=str_ind+1
end
oth_ind=0
while ( oth_ind<other.length )
cpy.set_char(cpy_ind,other.get_char(oth_ind))
cpy_ind=cpy_ind+1
oth_ind=oth_ind+1
end
while ( str_ind<length )
cpy.set_char(cpy_ind,get_char(str_ind))
str_ind=str_ind+1
cpy_ind=cpy_ind+1
end
cpy
end
if index<0
index = length+1+index
end
cpy = Word.new( length+other.length )
cpy_ind=0
str_ind=0
while ( str_ind<index )
cpy.set_char(cpy_ind,get_char(str_ind))
cpy_ind=cpy_ind+1
str_ind=str_ind+1
end
oth_ind=0
while ( oth_ind<other.length )
cpy.set_char(cpy_ind,other.get_char(oth_ind))
cpy_ind=cpy_ind+1
oth_ind=oth_ind+1
end
while ( str_ind<length )
cpy.set_char(cpy_ind,get_char(str_ind))
str_ind=str_ind+1
cpy_ind=cpy_ind+1
end
cpy
end
private
def check_length