sequence errors

new topic     » topic index » view thread      » older message » newer message

------=_NextPart_000_0007_01BFD244.F2BDD740
        charset="iso-8859-2"
Content-Transfer-Encoding: quoted-printable

functions like the one below are neccessary to avoid runtime errors.
if you do these operations on sequence with writing your own code, =
without any function, errors happen quick!, because you have to check so =
many things to avoid errors
sado)

With this function everything is clear and error is IMPOSSIBILE smile
Does anybody have any similar perfect functions for sequence slicing =
....

--eliminates members from sequence, including p1 and p2
global function TsSeq_Eliminate(sequence s,atom p1,atom p2)
 atom len
 len=3Dlength(s)

 if p1>p2+1 then
  printf(1,"\n%s",{"Error in function TsSeq_Eliminate: p1>p2"})
 end if

 p1-=3D1
 p2+=3D1

 if p1<0 then p1=3D0 end if
 if p1>len then p1=3Dlen end if
 if p2<1 then p2=3D1 end if
 if p2>len+1 then p2=3Dlen+1 end if

 return s[1..p1] & s[p2..len]
end function

sequence s,res

s=3D{1,2,3,4,5,6,7,8,9}

--res=3DTsSeq_Eliminate(s,1,1)
--res=3DTsSeq_Eliminate(s,2,3)
res=3DTsSeq_Eliminate(s,12,10)

?res

------=_NextPart_000_0007_01BFD244.F2BDD740
        charset="iso-8859-2"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-2" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3401" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>functions like the one below&nbsp;are =
neccessary to=20
avoid runtime errors.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>if you do these operations on sequence =
with writing=20
your own code, without any function, errors happen quick!, because you =
have to=20
check so many things to avoid errors</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>sado)</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>With this function everything is clear =
and error is=20
IMPOSSIBILE smile</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Does anybody have any similar perfect =
functions for=20
sequence slicing ....</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>--eliminates members from sequence, =
including p1=20
and p2<BR>global function TsSeq_Eliminate(sequence s,atom p1,atom=20
p2)<BR>&nbsp;atom len<BR>&nbsp;len=3Dlength(s)</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;if p1&gt;p2+1=20
then<BR>&nbsp;&nbsp;printf(1,"\n%s",{"Error in function TsSeq_Eliminate: =

p1&gt;p2"})<BR>&nbsp;end if</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial =
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;if p1&lt;0 then p1=3D0 end =
if<BR>&nbsp;if=20
p1&gt;len then p1=3Dlen end if<BR>&nbsp;if p2&lt;1 then p2=3D1 end =
if<BR>&nbsp;if=20
p2&gt;len+1 then p2=3Dlen+1 end if</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;return s[1..p1] &amp; =
s[p2..len]<BR>end=20
function</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>sequence s,res</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>s=3D{1,2,3,4,5,6,7,8,9}</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3DArial=20
<DIV><FONT face=3DArial=20
</FONT></DIV>
<DIV>&nbsp;</DIV>

------=_NextPart_000_0007_01BFD244.F2BDD740--

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu