home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / drdobbs / 1988 / 04 / thompson / thompson.exm
Text File  |  1979-12-31  |  2KB  |  69 lines

  1. topic 'which language'
  2.   ask ('What #mlanguage#m do you want to know more about ?',want,
  3.        [Pascal,C,Lisp,Prolog]).
  4.   do (?want).
  5.  
  6.   topic language.
  7.     window ().
  8.     say('
  9.          Some people make a distinction between AI and
  10.          "conventional" programming languages.  Though individual
  11.          languages certainly differ, for the most part, an AI language
  12.          is one that was developed at a place where they happen to be
  13.          doing AI.').
  14.     close_window ().
  15.   end. (* language *)
  16.  
  17.   topic Pascal.
  18.     say ('
  19.         When using Pascal to solve "AI types" of problems, you
  20.         usually have to design low-level routines to implement linked
  21.         list structures.').
  22.   end. (* Pascal *)
  23.  
  24.   (* topics for C, Lisp and Prolog would go here *)
  25.  
  26. end. (* which language *)
  27.  
  28. Example 1: Fragment of a KnowledgePro program, or knowledge base
  29.  
  30.  
  31. say ('One of the powerful features of #mLisp#m is the ability
  32. to easily manipulate #mlist structures#m.').
  33.  
  34. topic mark (find).
  35.   text = read ('threads.fil', concat ('/',?find), '/end').
  36.   window ().
  37.   say (?text).
  38.   close_window ().
  39. end. (* mark *)
  40.  
  41. Example 2: Using the default topic mark with hypertext
  42.  
  43.  
  44. topic animal.
  45.   :legs = 4. (* The default number of legs for an animal *)
  46.   dog ().    (* These commands are used for initialization *)
  47.   cat ().
  48.   bird ().
  49.   say ('
  50.        A dog has ',?dog:legs,' legs.
  51.        A cat has ',?cat:legs,' legs.
  52.        A bird has ',?bird:legs,' legs.').
  53.  
  54.   topic dog.
  55.   end. (* dog *)
  56.  
  57.   topic cat.
  58.   end. (* cat *)
  59.  
  60.   topic bird.
  61.     :legs = 2. (* override the default *)
  62.   end. (* bird *)
  63.  
  64. end. (* animal *)
  65.  
  66. Example 3: Nested topics showing how values are inherited
  67.  
  68.  
  69.