28.01.2015 Views

Hermes: A Tutorial and Reference Manual - Researcher - IBM

Hermes: A Tutorial and Reference Manual - Researcher - IBM

Hermes: A Tutorial and Reference Manual - Researcher - IBM

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

thetableisordered,theelementisinsertedattheendofthetable.Ifthe tableiskeyed,theDuplicateKeyexceptionisraisediftheinsertionwould operationisillegal.Ifithasahighertypestate,thetypestateislowered.If Thevaluemusthavetheelementtypestate.Ifithasalowertypestate,the fromasourcevariable.Thesourcevariablemustbeoftheelementtype. Theinsertstatementaddsanewelementtoatablebymovinginavalue 11.<strong>Hermes</strong>Operations111<br />

actlylikeinsert,exceptithasanadditionaloper<strong>and</strong>oftypepredefined!integer haveviolatedtherequirementofuniquekeys. whichspecieswheretoinserttheelement.Ifthispositionisnegative,or greaterthanthenumberofelementsinthetable,theexceptionRangeError takesprecedence. mayberaisedexactlyasforinsert,exceptthataRangeErrorexception israised.Otherwise,theelementisinsertedatthedesignatedposition.The positionsofearlierelementsinthetableremainthesame.Thepositionsof laterelements(ifany)areincreasedbyone.TheexceptionDuplicateKey Theinsert-atstatementislegalonlyfororderedtables.Itbehavesex-<br />

sinceitsvalueismoved<strong>and</strong>notcopied. Remove Aftereitherinsertorinsert-at,theelementvariableisuninitialized,<br />

noselectedelement,theexceptionNotFoundisraised.Thepreviousvalue, removedfromthetable<strong>and</strong>movedintothedestinationvariable.Ifthereis Theremovestatementhastwooper<strong>and</strong>s:adestinationelement,whichappearsafterthewordremove,<strong>and</strong>aselector.Thechosenselectedelementis<br />

Examples: simple{statement ifany,ofthedestinationvariableisdiscarded. removeCharfromString[0]; ::=removeelement{variablefromselector<br />

one.Ifthereisnone,anexceptionisraised.Thesecondstatementremoves thesmallestintegerfromIntbag|theintegerIsuchthatallintegersin empty. Extract IntbagareatleastaslargeasI.Itwillraiseanexceptionifthetableis removeMinfromIinIntBag Therststatementremovestherstcharacterfromthestring,ifthereis where(forallofJinIntbagwhere(J>=I));<br />

appearsafterthewordextract,<strong>and</strong>aselector.Allchosenselectedele- Theextractstatementhastwooper<strong>and</strong>s:adestinationtable,which simple{statement ::=extracttable{variablefromselector

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!