DIRECTORY GGUtility; GGUtilityImpl: CEDAR PROGRAM IMPORTS EXPORTS GGUtility = BEGIN FindEntityAndNeighbors: PROC [entity: REF ANY, entityList: LIST OF REF ANY] RETURNS [beforeEnt, ent, afterEnt: LIST OF REF ANY] = { lastE: LIST OF REF ANY _ NIL; eList: LIST OF REF ANY _ entityList; IF eList = NIL THEN ERROR EntityNotFound; UNTIL eList = NIL DO IF eList.first = entity THEN { beforeEnt _ lastE; ent _ eList; afterEnt _ eList.rest; RETURN}; lastE _ eList; eList _ eList.rest; ENDLOOP; SIGNAL EntityNotFound; }; EntityNotFound: PUBLIC SIGNAL = CODE; IsMember: PUBLIC PROC [entity: REF ANY, entityList: LIST OF REF ANY] RETURNS [BOOL] = { FOR list: LIST OF REF ANY _ entityList, list.rest UNTIL list = NIL DO IF list.first = entity THEN RETURN[TRUE]; ENDLOOP; RETURN[FALSE]; }; DeleteEntityFromList: PUBLIC PROC [entity: REF ANY, entityList: LIST OF REF ANY] RETURNS [smallerList: LIST OF REF ANY] = { beforeEnt, ent, afterEnt: LIST OF REF ANY; notFound: BOOL _ FALSE; [beforeEnt, ent, afterEnt] _ FindEntityAndNeighbors[entity, entityList]; IF notFound THEN RETURN[entityList]; IF beforeEnt = NIL THEN smallerList _ afterEnt ELSE { beforeEnt.rest _ afterEnt; smallerList _ entityList; }; }; -- end of DeleteEntityFromList AppendList: PUBLIC PROC [list1, list2: LIST OF REF ANY] RETURNS [result: LIST OF REF ANY] = { pos: LIST OF REF ANY; newCell: LIST OF REF ANY; IF list1 = NIL THEN RETURN[list2]; result _ CONS[list1.first, NIL]; pos _ result; FOR l: LIST OF REF ANY _ list1.rest, l.rest UNTIL l = NIL DO newCell _ CONS[l.first, NIL]; pos.rest _ newCell; pos _ newCell; ENDLOOP; pos.rest _ list2; }; END. άGGUtilityImpl.mesa Last edited by Bier on August 16, 1985 11:23:39 pm PDT. Contents: General Purpose routines for use by Gargoyle. Utility Functions for LIST OF REF ANY. Non-destructive (copies the first list). Κk˜Ihead1™J™7J™8šΟk ˜ Jšœ ˜ —J˜šœœ˜Jšœ˜Jšœ˜—Jš˜J˜Iproc˜Jš œœœœœ™&J™šΟnœœ œœœœœœœœœœœ˜ƒJš œœœœœœ˜Jš œœœœœ˜$Jšœ œœœ˜)šœ œ˜Jšœœ˜Jšœ7œ˜?Jšœ˜Jšœ˜—Jšœ˜Jšœ˜Jšœ˜J˜—Jšœœœœ˜%J˜šžœ œ œœœœœœœœ˜Wšœœœœœœœ˜EJšœœœœ˜)—Jšœ˜Jšœœ˜J˜—šžœ œ œœœœœœœœœœœ˜{Jš œœœœœ˜*Jšœ œœ˜JšœH˜HJšœ œœ ˜$Jšœ œœ˜.šœ˜Jšœ˜Jšœ˜J˜—JšœΟc˜!J˜—šž œ œœœœœœ œœœœ˜]Jš œœœœœ˜Jš œ œœœœ˜J™(Jšœ"˜"Jšœ ˜ Jšœ ˜ š œœœœœ&˜