07-lists.lpt 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. PSL Manual 7 February 1983 List Structure
  2. section 7.0 page 7.1
  3. CHAPTER 7 CHAPTER 7 CHAPTER 7
  4. LIST STRUCTURE LIST STRUCTURE LIST STRUCTURE
  5. 7.1. Introduction to Lists and Pairs . . . . . . . . . 7.1
  6. 7.2. Basic Functions on Pairs . . . . . . . . . . . 7.2
  7. 7.3. Functions for Manipulating Lists. . . . . . . . . 7.4
  8. 7.3.1. Selecting List Elements . . . . . . . . . 7.4
  9. 7.3.2. Membership and Length of Lists . . . . . . . 7.6
  10. 7.3.3. Constructing, Appending, and Concatenating Lists . 7.6
  11. 7.3.4. Lists as Sets. . . . . . . . . . . . . 7.7
  12. 7.3.5. Deleting Elements of Lists . . . . . . . . 7.8
  13. 7.3.6. List Reversal. . . . . . . . . . . . . 7.9
  14. 7.4. Functions for Building and Searching A-Lists. . . . . 7.10
  15. 7.5. Substitutions . . . . . . . . . . . . . . . 7.11
  16. 7.1. Introduction to Lists and Pairs 7.1. Introduction to Lists and Pairs 7.1. Introduction to Lists and Pairs
  17. ____ The pair is a fundamental PSL data type, and is one of the major
  18. ____ ____ attractions of LISP programming. A pair consists of a two-item structure.
  19. Car Cdr Car Cdr In PSL the first element is called the Car and the second the Cdr; in other
  20. LISPs, the physical relationship of the parts may be different. An
  21. Car Car illustration of the tree structure is given below as a box diagram; the Car
  22. Cdr Cdr and the Cdr are each represented as a portion of the box.
  23. -----------------
  24. || Car | Cdr ||
  25. -----------------
  26. As an example, a tree written as ((A . B) . (C . D)) in dot-notation is
  27. drawn below as a box diagram.
  28. -----------------
  29. || / | \ ||
  30. ----/-------\----
  31. / \
  32. ----------------- -----------------
  33. || A | B || || C | D ||
  34. ----------------- -----------------
  35. The box diagrams are tedious to draw, so dot-notation is normally used.
  36. ____ Note that a space is left on each side of the . to ensure that pairs are
  37. _____ not confused with floats. Note also that in RLISP a dot may be used as the List Structure 7 February 1983 PSL Manual
  38. page 7.2 section 7.1
  39. Cons Cons infix operator for the function Cons, as in the expression x := 'y . 'z;,
  40. ____ or as part of the notation for pairs, as in the expression x := '(y . z);
  41. (see Section 3.3.3).
  42. An important special case occurs frequently enough that it has a special
  43. ____ notation. This is a list of items, terminated by convention with the id
  44. NIL. The dot and surrounding parentheses are omitted, as well as the
  45. trailing NIL. Thus
  46. (A . (B . (C . NIL)))
  47. can be represented in list-notation as
  48. (A B C)
  49. 7.2. Basic Functions on Pairs 7.2. Basic Functions on Pairs 7.2. Basic Functions on Pairs
  50. ____ The following are elementary functions on pairs. All functions in this
  51. Chapter which require pairs as parameters signal a type mismatch error if
  52. the parameter given is not a pair.
  53. Cons Cons _ ___ _ ___ ____ ____ (Cons U:any V:any): pair expr
  54. Eq ____ Eq _ Returns a pair which is not Eq to anything else and has U as its
  55. Car Cdr Car _ Cdr Car part and V as its Cdr part. In RLISP syntax the dot, ".", is
  56. Cons Cons an infix operator meaning Cons. Thus (A . (B . fn C) . D) is
  57. Cons Cons Cons Cons Cons Cons equivalent to Cons (A, Cons (Cons (B, fn C), D)). See Section
  58. 3.3.3 for more discussion of how dot is read.
  59. Car Car _ ____ ___ ____ ________ ____ (Car U:pair): any open-compiled, expr
  60. _ The left part of U is returned. A type mismatch error occurs if
  61. _ ____ _ U is not a pair, except when U is NIL. Then NIL is returned.
  62. Car Cons Car Cons (Car (Cons a b)) ==> a.
  63. Cdr Cdr _ ____ ___ ____ ________ ____ (Cdr U:pair): any open-compiled, expr
  64. _ The right part of U is returned. A type mismatch error occurs if
  65. _ ____ _ U is not a pair, except when U is NIL. Then NIL is returned.
  66. Cdr Cons Cdr Cons (Cdr (Cons a b)) ==> b.
  67. Car Cdr Car Cdr The composites of Car and Cdr are supported up to four levels. PSL Manual 7 February 1983 List Structure
  68. section 7.2 page 7.3
  69. Car Cdr Car Cdr Car Cdr
  70. Caar Cdar Cadr Cddr Caar Cdar Cadr Cddr Caar Cdar Cadr Cddr
  71. Caaar Cdaar Cadar Cddar Caadr Cdadr Caddr Cdddr Caaar Cdaar Cadar Cddar Caadr Cdadr Caddr Cdddr Caaar Cdaar Cadar Cddar Caadr Cdadr Caddr Cdddr
  72. Caaaar Cadaar Caadar Caddar Caaadr Cadadr Caaddr Cadddr Caaaar Cadaar Caadar Caddar Caaadr Cadadr Caaddr Cadddr Caaaar Cadaar Caadar Caddar Caaadr Cadadr Caaddr Cadddr
  73. Cdaaar Cddaar Cdadar Cdddar Cdaadr Cddadr Cdaddr Cddddr Cdaaar Cddaar Cdadar Cdddar Cdaadr Cddadr Cdaddr Cddddr Cdaaar Cddaar Cdadar Cdddar Cdaadr Cddadr Cdaddr Cddddr
  74. ____ ____ ____ expr expr These are all exprs of one argument. They may return any type
  75. and are generally open-compiled. An example of their use is that
  76. Cddar Cdr Cdr Car Car Cdr Cddar Cdr Cdr Car Car Cdr Cddar p is equivalent to Cdr Cdr Car p. As with Car and Cdr, a
  77. type mismatch error occurs if the argument does not possess the
  78. specified component.
  79. As an alternative to employing chains of CxxxxR to obscure depths,
  80. ____ particularly in extracting elements of a list, consider the use of the
  81. First Second Third Fourth Nth First Second Third Fourth Nth functions First, Second, Third, Fourth, or Nth (Section 7.3.1), or possibly
  82. even the Defstruct package (Section 17.6).
  83. NCons NCons _ ___ ____ ____ ________ ____ (NCons U:any): pair open-compiled, expr
  84. Cons Cons _ Equivalent to Cons (U, NIL).
  85. XCons XCons _ ___ _ ___ ____ ____ ________ ____ (XCons U:any V:any): pair open-compiled, expr
  86. Cons Cons _ _ Equivalent to Cons (V, U).
  87. Copy Copy _ ___ ___ ____ (Copy X:any): any expr
  88. ____ _ Copies all pairs in X, but does not make copies of atoms
  89. (including vectors and strings). For example, if A is
  90. ([2 5] "ATOM")
  91. and B is the result of (Copy A), then
  92. (Eq A B) is NIL
  93. but (Eq (Car A) (Car B)) is T
  94. and (Eq (Cadr A) (Cadr B)) is T
  95. TotalCopy Copy TotalCopy Copy See TotalCopy in Section 8.5. Note that Copy is recursive and
  96. will not terminate if its argument is a circular list.
  97. See Chapter 8 for other relevant functions.
  98. The following functions are known as "destructive" functions, because
  99. they change the structure of the pair given as their argument, and
  100. consequently change the structure of the object containing the pair. They
  101. are most frequently used for various "efficient" functions (e.g. the List Structure 7 February 1983 PSL Manual
  102. page 7.4 section 7.2
  103. ReverseIP NConc DeleteIP ReverseIP NConc DeleteIP non-copying ReverseIP and NConc functions, and destructive DeleteIP) and to
  104. build structures that have deliberately shared sub-structure. They are
  105. also capable of creating circular structures, which create havoc with
  106. careful careful normal printing and list traversal functions. Be careful using them.
  107. RplacA RplacA _ ____ _ ___ ____ ____ ________ ____ (RplacA U:pair V:any): pair open-compiled, expr
  108. Car Car _ _ _ The Car of the pair U is replaced by V, and the modified U is
  109. _ _ returned. (If U is (a . b) then (V .b) is returned). A type
  110. _ mismatch error occurs if U is not a pair.
  111. RplacD RplacD _ ____ _ ___ ____ ____ ________ ____ (RplacD U:pair V:any): pair open-compiled, expr
  112. Cdr Cdr _ _ _ The Cdr of the pair U is replaced by V, and the modified U is
  113. _ _ returned. (If U is (a . b) then (a . V) is returned). A type
  114. _ mismatch error occurs if U is not a pair.
  115. RplacW RplacW _ ____ _ ____ ____ ____ (RplacW A:pair B:pair): pair expr
  116. Car Car Car _ Car Replaces the whole pair: the Car of A is replaced with the Car
  117. Cdr Cdr _ Cdr _ Cdr _ _ of B, and the Cdr of A with the Cdr of B. The modified A is
  118. returned.
  119. [??? Should we add some more functions here someday? Probably the [??? Should we add some more functions here someday? Probably the [??? Should we add some more functions here someday? Probably the
  120. RLISP guys that do arbitrary depth member type stuff. ???] RLISP guys that do arbitrary depth member type stuff. ???] RLISP guys that do arbitrary depth member type stuff. ???]
  121. 7.3. Functions for Manipulating Lists 7.3. Functions for Manipulating Lists 7.3. Functions for Manipulating Lists
  122. ____ ____ The following functions are meant for the special pairs which are lists,
  123. as described in Section 7.1. Note that the functions described in Chapter
  124. 8 can also be used on lists.
  125. [??? Make some mention of mapping with FOR...COLLECT and such like. [??? Make some mention of mapping with FOR...COLLECT and such like. [??? Make some mention of mapping with FOR...COLLECT and such like.
  126. ???] ???] ???]
  127. 7.3.1. Selecting List Elements 7.3.1. Selecting List Elements 7.3.1. Selecting List Elements
  128. First First _ ____ ___ _____ (First L:pair): any macro
  129. Car Car _ A synonym for Car L. PSL Manual 7 February 1983 List Structure
  130. section 7.3 page 7.5
  131. Second Second _ ____ ___ _____ (Second L:pair): any macro
  132. Cadr Cadr _ A synonym for Cadr L.
  133. Third Third _ ____ ___ _____ (Third L:pair): any macro
  134. Caddr Caddr _ A synonym for Caddr L.
  135. Fourth Fourth _ ____ ___ _____ (Fourth L:pair): any macro
  136. Cadddr Cadddr _ A synonym for Cadddr L.
  137. Rest Rest _ ____ ___ _____ (Rest L:pair): any macro
  138. Cdr Cdr _ A synonym for Cdr L.
  139. LastPair LastPair _ ____ ___ ____ (LastPair L:pair): any expr
  140. ____ ____ Last pair of a list. It is often useful to think of this as a
  141. pointer to the last element for use with destructive functions
  142. RplacA RplacA _ such as RplacA. Note that if L is atomic a type mismatch error
  143. occurs.
  144. (De LastPair (L)
  145. (Cond ((Null (Rest L)) L)
  146. (T (LastPair (Rest L)))))
  147. LastCar LastCar _ ___ ___ ____ (LastCar L:any): any expr
  148. ____ _ Returns the last element of the list L. A type mismatch error
  149. First LastPair _ First LastPair _ results if L is not a list. Equivalent to First LastPair L.
  150. Nth Nth _ ____ _ _______ ___ ____ (Nth L:pair N:integer): any expr
  151. ____ _ _ Returns the Nth element of the list L. If L is atomic or
  152. _ contains fewer than N elements, an out of range error occurs.
  153. First PNth First PNth Equivalent to (First (PNth L N)).
  154. PNth PNth _ ____ _ _______ ___ ____ (PNth L:list N:integer): any expr
  155. ____ ____ _ Returns list starting with the Nth element of a list L. Note
  156. that it is often useful to view this as a pointer to the Nth
  157. RplacA _ RplacA element of L for use with destructive functions such as RplacA.
  158. _ _ If L is atomic or contains fewer than N elements, an out of range
  159. error occurs. List Structure 7 February 1983 PSL Manual
  160. page 7.6 section 7.3
  161. (De PNth (L N)
  162. (Cond ((Leq N 1) L)
  163. (T (PNth (Cdr L) (Sub1 N)))))
  164. 7.3.2. Membership and Length of Lists 7.3.2. Membership and Length of Lists 7.3.2. Membership and Length of Lists
  165. Member Member _ ___ _ ____ _____ _______ ____ (Member A:any L:list): extra-boolean expr
  166. Equal _ Equal ____ Returns NIL if A is not Equal to some top level element of list
  167. _ _ L; otherwise it returns the remainder of L whose first element is
  168. _ A.
  169. (De Member (A L)
  170. (Cond((Null L) Nil)
  171. ((Equal A (First L)) L)
  172. (T (Member A (Rest L)))))
  173. MemQ MemQ _ ___ _ ____ _____ _______ ____ (MemQ A:any B:list): extra-boolean expr
  174. Member Eq Member Eq Same as Member, but an Eq check is used for comparison.
  175. (De Memq (A L)
  176. (Cond((Null L) Nil)
  177. ((Eq A (First L)) L)
  178. (T (Memq A (Rest L)))))
  179. Length Length _ ___ _______ ____ (Length X:any): integer expr
  180. ____ _ The top level length of the list X is returned.
  181. (De Length (X)
  182. (Cond((Atom X) 0)
  183. (T (Plus (Length X) 1))))
  184. 7.3.3. Constructing, Appending, and Concatenating Lists 7.3.3. Constructing, Appending, and Concatenating Lists 7.3.3. Constructing, Appending, and Concatenating Lists
  185. List List _ ___ ____ _____ (List [U:any]): list fexpr
  186. ____ ____ Construct a list of the evaluated arguments. A list of the
  187. _ evaluation of each element of U is returned.
  188. Append Append _ ____ _ ____ ____ ____ (Append U:list V:list): list expr
  189. ____ _ Returns a constructed list in which the last element of U is
  190. _ ____ _ _ followed by the first element of V. The list U is copied, but V PSL Manual 7 February 1983 List Structure
  191. section 7.3 page 7.7
  192. is not.
  193. (De Append (U V)
  194. (Cond ((Null U) V)
  195. (T (Cons (Car U) (Append (Cdr U) V)))))
  196. NConc NConc _ ____ _ ____ ____ ____ (NConc U:list V:list): list expr
  197. Append Append _ _ Destructive version of Append. Concatenates V to U without
  198. Cdr _ Cdr _ _ copying U. The last Cdr of U is modified to point to V. See the
  199. warning on page 7.3 about the use of destructive functions.
  200. (De Nconc (U V)
  201. (Cond ((Null U) V)
  202. (T (Rplacd (Lastcdr U V)))))
  203. AConc AConc _ ____ _ ___ ____ ____ (AConc U:list V:any): list expr
  204. _ ____ _ Destructively adds element V to the tail of list U.
  205. LConc LConc ___ ____ ____ ____ ____ ____ (LConc PTR:list ELEM:list): list expr
  206. NConc NConc Effectively NConc, but avoids scanning from the front to the end
  207. RPLACD ___ RPLACD ___ ____ of PTR for the RPLACD(PTR, ELEM) by maintaining a pointer to end
  208. LastPair ____ ___ ___ ____ LastPair ____ of the list PTR. PTR is (list . LastPair list). Returns updated
  209. ___ ___ PTR. PTR should be initialized to NIL . NIL before calling the
  210. ____ first time. Used to build lists from left to right.
  211. TConc TConc ___ ____ ____ ___ ____ ____ (TConc PTR:list ELEM:any): list expr
  212. AConc AConc Effectively AConc, but avoids scanning from the front to the end
  213. RPLACD List ___ RPLACD ___ List ____ of PTR for the RPLACD(PTR, List(ELEM)) by maintaining a pointer
  214. LastPair ____ ___ ___ ____ LastPair ____ to end of the list PTR. PTR is (list . LastPair list). Returns
  215. ___ ___ updated PTR. PTR should be initialized to NIL . NIL before
  216. ____ calling the first time. Used to build lists from left to right.
  217. 7.3.4. Lists as Sets 7.3.4. Lists as Sets 7.3.4. Lists as Sets
  218. ____ A set is a list in which each element occurs only once. Order of
  219. elements does not matter, so these functions may not preserve order.
  220. Adjoin Adjoin _______ ___ ___ ____ ____ ____ (Adjoin ELEMENT:any SET:list): list expr
  221. Equal _______ ___ Equal Add ELEMENT to SET if it is not already on the top level. Equal
  222. is used to test for equality. List Structure 7 February 1983 PSL Manual
  223. page 7.8 section 7.3
  224. AdjoinQ AdjoinQ _______ ___ ___ ____ ____ ____ (AdjoinQ ELEMENT:any SET:list): list expr
  225. Adjoin Eq Adjoin Eq _______ ___ Adjoin using Eq for the test whether ELEMENT is already in SET.
  226. Union Union _ ____ _ ____ ____ ____ (Union X:list Y:list): list expr
  227. Set union.
  228. UnionQ UnionQ _ ____ _ ____ ____ ____ (UnionQ X:list Y:list): list expr
  229. Eq Union Eq Union Eq version of Union.
  230. InterSection InterSection _ ____ _ ____ ____ ____ (InterSection U:list V:list): list expr
  231. Set intersection.
  232. InterSectionQ InterSectionQ _ ____ _ ____ ____ ____ (InterSectionQ U:list V:list): list expr
  233. Eq InterSection Eq InterSection Eq version of InterSection.
  234. List2Set List2Set ___ ____ ____ ____ (List2Set SET:list): list expr
  235. Equal ___ Equal Remove redundant elements from the top level of SET using Equal.
  236. List2SetQ List2SetQ ___ ____ ____ ____ (List2SetQ SET:list): list expr
  237. Eq ___ Eq Remove redundant elements from the top level of SET using Eq.
  238. 7.3.5. Deleting Elements of Lists 7.3.5. Deleting Elements of Lists 7.3.5. Deleting Elements of Lists
  239. xxxIP xxx xxxIP xxx Note that functions with names of the form xxxIP indicate that xxx is
  240. done InPlace.
  241. Delete Delete _ ___ _ ____ ____ ____ (Delete U:any V:list): list expr
  242. _ _ Returns V with the first top level occurrence of U removed from
  243. _ _ it. That portion of V before the first occurrence of U is
  244. copied.
  245. (De Delete (U V)
  246. (Cond((Null V) Nil)
  247. ((Equal (First V) U) (Rest V))
  248. (T (Cons (First V) (Delete U (Rest V)))))) PSL Manual 7 February 1983 List Structure
  249. section 7.3 page 7.9
  250. Del Del _ ________ _ ___ _ ____ ____ ____ (Del F:function U:any V:list): list expr
  251. Delete Delete _ Generalized Delete function with F as the comparison function.
  252. DeletIP DeletIP _ ___ _ ____ ____ ____ (DeletIP U:any V:list): list expr
  253. Delete RplacD Delete _ RplacD _ Destructive Delete; modifies V using RplacD. Do not depend on V
  254. ____ itself correctly referring to list.
  255. DelQ DelQ _ ___ _ ____ ____ ____ (DelQ U:any V:list): list expr
  256. Eq _ _ Eq Delete U from V, using Eq for comparison.
  257. DelQIP DelQIP _ ___ _ ____ ____ ____ (DelQIP U:any V:list): list expr
  258. DelQ DeletIP DelQ DeletIP Destructive version of DelQ; see DeletIP.
  259. DelAsc DelAsc _ ___ _ _ ____ _ ____ ____ (DelAsc U:any V:a-list): a-list expr
  260. _ _ Remove first (U . xxx) from V.
  261. DelAscIP DelAscIP _ ___ _ _ ____ _ ____ ____ (DelAscIP U:any V:a-list): a-list expr
  262. DelAsc DelAsc Destructive DelAsc.
  263. DelatQ DelatQ _ ___ _ _ ____ _ ____ ____ (DelatQ U:any V:a-list): a-list expr
  264. Eq _ _ Eq _ Delete first (U . xxx) from V, using Eq to check equality with U.
  265. DelatQIP DelatQIP _ ___ _ _ ____ _ ____ ____ (DelatQIP U:any V:a-list): a-list expr
  266. DelatQ DelatQ Destructive DelatQ.
  267. 7.3.6. List Reversal 7.3.6. List Reversal 7.3.6. List Reversal
  268. Reverse Reverse _ ____ ____ ____ (Reverse U:list): list expr
  269. _ Returns a copy of the top level of U in reverse order. List Structure 7 February 1983 PSL Manual
  270. page 7.10 section 7.3
  271. (De Reverse (U)
  272. (Prog (W)
  273. (While U
  274. (ProgN
  275. (Setq W (Cons (Car U) W))
  276. (Setq U (Cdr U))))
  277. (Return W)))
  278. ReversIP ReversIP _ ____ ____ ____ (ReversIP U:list): list expr
  279. Reverse Reverse Destructive Reverse.
  280. 7.4. Functions for Building and Searching A-Lists 7.4. Functions for Building and Searching A-Lists 7.4. Functions for Building and Searching A-Lists
  281. Assoc Assoc _ ___ _ _ ____ ____ ___ ____ (Assoc U:any V:a-list): {pair, NIL} expr
  282. Car _ Car _ ____ _ If U occurs as the Car portion of an element of the a-list V, the
  283. ____ _ pair in which U occurred is returned, else NIL is returned.
  284. Assoc Assoc _ ____ Assoc might not detect a poorly formed a-list so an invalid
  285. Car Cdr Car Cdr construction may be detected by Car or Cdr.
  286. (De Assoc (U V)
  287. (Cond ((Null V) Nil)
  288. ((Atom (Car V))
  289. (Error 000 (List V "is a poorly formed alis
  290. ((Equal U (Caar V)) (Car V))
  291. (T (Assoc U (Cdr V)))))
  292. Atsoc Atsoc __ ___ __ ___ ___ ____ (Atsoc R1:any R2:any): any expr
  293. Car Eq Eq Assoc __ ____ Car Eq __ Eq Assoc Scan R2 for pair with Car Eq R1. Eq version of Assoc.
  294. Ass Ass _ ________ _ ___ _ _ ____ ____ ___ ____ (Ass F:function U:any V:a-list): {pair, NIL} expr
  295. Ass Assoc Ass Assoc _ Ass is a generalized Assoc function. F is the comparison
  296. function.
  297. SAssoc SAssoc _ ___ _ _ ____ __ ________ ___ ____ (SAssoc U:any V:a-list FN:function): any expr
  298. _ ____ _ _ _ Searches the a-list V for an occurrence of U. If U is not in the
  299. _ ____ __ a-list, the evaluation of function FN is returned. PSL Manual 7 February 1983 List Structure
  300. section 7.4 page 7.11
  301. (De SAssoc (U V FN)
  302. (Cond ((Null V) (FN))
  303. ((Equal U (Caar V)) (Car V))
  304. (T (SAssoc U (Cdr V) FN))))
  305. Pair Pair _ ____ _ ____ _ ____ ____ (Pair U:list V:list): a-list expr
  306. _ _ ____ U and V are lists which must have an identical number of
  307. ____ elements. If not, an error occurs. Returned is a list in which
  308. Car ____ Car ____ _ each element is a pair, the Car of the pair being from U and the
  309. Cdr Cdr _ Cdr being the corresponding element from V.
  310. (De Pair (U V)
  311. (Cond ((And U V)(Cons (Cons (Car U)(Car V))
  312. (Pair (Cdr U)(Cdr V))))
  313. ((Or U V)(Error 000 "Different length lists i
  314. (T Nil)))
  315. 7.5. Substitutions 7.5. Substitutions 7.5. Substitutions
  316. Subst Subst _ ___ _ ___ _ ___ ___ ____ (Subst U:any V:any W:any): any expr
  317. _ _ Returns the result of substituting U for all occurrences of V in
  318. _ _ _ W. Copies all of W which is not replaced by U. The test used is
  319. Equal Equal Equal.
  320. (De Subst (U V W)
  321. (Cond ((Null W) Nil)
  322. ((Equal V W) U)
  323. ((Atom W) W)
  324. (T (Cons (Subst U V (Car W))(Subst U V (Cdr
  325. SubstIP SubstIP _ ___ _ ___ _ ___ ___ ____ (SubstIP U:any V:any W:any): any expr
  326. Subst Subst Destructive Subst.
  327. SubLis SubLis _ _ ____ _ ___ ___ ____ (SubLis X:a-list Y:any): any expr
  328. Subst Subst This performs a series of Substs in parallel. The value returned
  329. Cdr Cdr is the result of substituting the Cdr of each element of the
  330. Car _ ____ _ Car a-list X for every occurrence of the Car part of that element in
  331. _ Y. List Structure 7 February 1983 PSL Manual
  332. page 7.12 section 7.5
  333. (De SubLis (X Y)
  334. (Cond
  335. ((Null X) Y)
  336. (T
  337. (Prog (U)
  338. (Setq U (Assoc Y X))
  339. (Return
  340. (Cond
  341. (U (Cdr U))
  342. ((Atom Y) Y)
  343. (T (Cons (SubLis X (Car Y)) (SubLis X (Cdr Y))
  344. SublA SublA _ _ ____ _ ___ ___ ____ (SublA U:a-list V:any): any expr
  345. Eq SubLis Eq SubLis Eq version of SubLis; replaces atoms only.