home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / jËzyki_programowania / logo / powerlogo / libs / lisp < prev    next >
Text File  |  1992-11-05  |  1KB  |  73 lines

  1.  
  2. ; lisp - a library of LISP-like primitives for Power LOGO
  3. ; Tony L Belding
  4.  
  5. if namep "lispnames [ unbury :lispnames ] [ ]
  6.  
  7. make "remove [
  8.     procedure [ [ :card :deck ] ]
  9.  
  10.     ; removes all occurences of object CARD from object DECK
  11.  
  12.     if not memberp :card :deck [
  13.         op :deck
  14.     ] [
  15.         if = :card first :deck [
  16.             op remove :card bf :deck
  17.         ] [
  18.             op fput first :deck remove :card bf :deck
  19.         ]
  20.     ]
  21. ]
  22.  
  23. make "delete [
  24.     procedure [ [ :card :deck ] ]
  25.  
  26.     ; a shortcut for:  make "object remove :key :object
  27.     ;    instead use:  delete :key "object
  28.  
  29.     ; This is not quirky about the first item like LISP delete is.
  30.  
  31.     make :deck remove :card thing :deck
  32.     op thing :deck
  33. ]
  34.  
  35. make "push [
  36.     procedure [ [ :Item :List ] ]
  37.  
  38.     ; push adds an item to the beginning of a list
  39.     make :List firstput :Item thing :List
  40.     op thing :List
  41. ]
  42.  
  43. make "pop [
  44.     procedure [ [ :List ] [ ] [ :Item ] ]
  45.  
  46.     ; pop removes the first item from a list
  47.     make "Item first thing :List
  48.     make :List butfirst thing :List
  49.     op :Item
  50. ]
  51.  
  52. make "assoc [
  53.     procedure [ [ :key :alist ] ]
  54.  
  55.     ; equivalent to LISP ASSOC primitive
  56.     ; uses a key value to extract a sublist from an association list
  57.  
  58.     if emptyp :alist
  59.         [ op [ ] ] [ ]
  60.     if ( = :key first first :alist ) [
  61.         op first :alist
  62.     ] [
  63.         op assoc :key butfirst :alist
  64.     ]
  65. ]
  66.  
  67. make "lisp [ procedure [ ] ]
  68.  
  69. make "lispnames [ lispnames remove delete push pop assoc lisp ]
  70.  
  71. bury :lispnames
  72.  
  73. ; end of listing