MTS 8: LISP and SLIP in MTS
June 1976
WRITE (6, 100) SYMBOL
100 FORMAT (5X,A8,15H IS IN LIST LST)
GO TO 30
20 CONTINUE
WRITE (6,110) SYMBOL
110 FORMAT (5X,A8,19H IS NOT IN LIST LST)
30 CONTINUE
CALL IRARDR (LRDR)
As can be seen, the use of the advance functions must be preceded by
the creation of the Reader. Similarly, after the task has been
accomplished, the programmer should erase the Reader.
Suppose we wish to write a subroutine that searches a list structure
with alias LST for all occurrences of the symbol S. If found, S is
removed; otherwise nothing happens.
SUBROUTINE SEARCH (LST,S)
DOUBLE PRECISION ADVSWL,ADVSWR,X,S,LST
LSTRDR = LRDROV (LST)
100 CONTINUE
X = ADVSWR (LSTRDR,IFLG)
IF(IFLG.NE.0) GO TO 200
IF(X.NE.S) GO TO 100
IPOINT = LPNTR (LSTRDR)
CALL ADVSWL (LSTRDR,IFLG)
CALL DELETE (IPOINT)
GO TO 100
200 CONTINUE
CALL IRARDR(LSTRDR)
RETURN
END
Note that the second call to the advance function in the opposite,
left, direction is necessary because of the DELETE operation.
The following three examples illustrate the use of these functions.
WHATS = ADVLWR(KADR1,IFLAG1)
modifies the LPNTR field of the Reader with alias KADR1 to point to the
cell immediately to the right of the one it pointed to before execution
of the function. If this new cell is the Header of the list involved,
IFLAG1 is set to -1, and WHATS is essentially garbage. Otherwise,
IFLAG1 is 0, and WHATS contains the datum of the SLIP-cell currently
pointed to by the Reader. Note that no descent is made to a sublist
even if a reference to it is encountered.
The statement
IUP = INTGER(ADVSNL(NRD2,IFLAG2))
134 SLIP