home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_200 / 297_01 / help.spr < prev    next >
Text File  |  1992-01-01  |  13KB  |  508 lines

  1. /* help.spr */
  2. /* information on predicates */
  3. /* load this with (consult "help.spr") and then 
  4.  * type (help) or (help My_predicate)
  5.  */
  6.  
  7. ((help)
  8.  (info P Args Text See_also)
  9.  (writes "***********************************")
  10.  (nl)
  11.  (display P)
  12.  (nl)
  13.  (help_builtin P)
  14.  (help_args Args)
  15.  (help_text Text)
  16.  (help_see_also See_also)
  17.  (nl)
  18.  (pause)
  19.  (fail)
  20. )
  21. (help)
  22.  
  23. ((help P)
  24.  (info P Args Text See_also)
  25.  (help_builtin P)
  26.  (help_args Args)
  27.  (help_text Text)
  28.  (help_see_also See_also)
  29. )
  30. ((help_builtin P)
  31.  (builtin P)
  32.  (cut)
  33.  (display P)
  34.  (writes " is a builtin.")
  35.  (nl)
  36. )
  37. (help_builtin _)
  38.  
  39. ((help_args Args)
  40.  (writes "Expected argument types: ")
  41.  (nl)
  42.  (help_args1 Args)
  43.  (nl)
  44. )
  45. ((help_args1 (()))
  46.  (cut)
  47. )
  48. ((help_args1 (X))
  49.  (atom X)
  50.  (cut)
  51.  (writes "Variable number of ")
  52.  (display X)
  53.  (nl)
  54. )
  55. ((help_args1 (Head))
  56.  (cut)
  57.  (help_args2 Head)
  58.  (nl)
  59. )
  60. ((help_args1 (Head | Tail))
  61.  (help_args2 Head)
  62.  (nl)
  63.  (writes "then")
  64.  (nl)
  65.  (help_args1 Tail)
  66. )
  67. (help_args1 ())
  68.  
  69. ((help_args2 (X))
  70.  (display X)
  71.  (cut)
  72. )
  73. ((help_args2 (First | Rest))
  74.  (display First)
  75.  (writes " or ")
  76.  (help_args2 Rest)
  77. )
  78.  
  79. ((help_text (Head | Tail))
  80.  (cut)
  81.  (writes Head)
  82.  (nl)
  83.  (help_text Tail)
  84. )
  85. (help_text ())
  86.  
  87. ((help_see_also L)
  88.  (nl)
  89.  (writes "See also: ")
  90.  (help_see_also1 L)
  91. )
  92. ((help_see_also1 (H | T))
  93.  (cut)
  94.  (display H)
  95.  (writes " ")
  96.  (help_see_also1 T)
  97. )
  98. (help_see_also1 ())
  99.  
  100. ((pause )
  101.  (nl)(writes "Press Return for more..")
  102.  (get X)
  103.  (pause_action X)
  104. )
  105.  
  106. ((pause_action 113)(cut)(abort))/* ie typing a q causes the program to end */
  107. ((pause_action _))
  108.  
  109. (info tell ((string))
  110.     ("Redirects current output stream to file."
  111.      "the file ""user"" represents the console"
  112.     )
  113.     (told telling)
  114. )
  115. (info telling ((variable string))
  116.     ("Unifies argument with name of current output stream.")
  117.     (told tell)
  118. )
  119. (info told ()
  120.     ("Closes current output stream if different from console.")
  121.     (tell telling)
  122. )
  123. (info display ((anything))
  124.     ("Writes first argument on current output stream."
  125.     "Default current output stream is console.")
  126.     (writes put nl)
  127. )
  128. (info display ((anything) (variable integer ))
  129.     ("Writes first argument on current output stream."
  130.     "Default current output stream is console."
  131.     "Unifies second argument with number of chars output.")
  132.     (writes put nl)
  133. )
  134. (info writes ((string))
  135.     ("Writes without inverted commas the string to current output stream.")
  136.     (display nl put)
  137. )
  138. (info nl (())
  139.     ("Writes a newline on current output stream.")
  140.     (display writes put)
  141. )
  142. (info put ((integer))
  143.     ("Displays a character whose ascii code is the integer.") 
  144.     (display writes nl)
  145. )
  146. (info see ((string))
  147.     ("Current input stream becomes argument which is a file name.")
  148.     (seeing seen)
  149. )
  150. (info consult ((string atom))
  151.     ("Loads named file adds it to current work space."
  152.      "Does not remove existing clauses."
  153.     )
  154.         ()
  155. )
  156. (info seeing ((string variable))
  157.     ("Unifies argument with name of current input stream.")
  158.     (see seen)
  159. )
  160. (info seen ()
  161.     ("Closes current input stream if different from console.")
  162.     (see seeing)
  163. )
  164. (info read ((anything))
  165.     ("Reads next (full) prolog term in input stream."
  166.      "Unifies this with argument."
  167.     )
  168.     (read_word get)
  169. )
  170. (info read_word ((variable string))
  171.     ("Reads next sequence of consecutive non blank characters."
  172.      "Unifies string thus formed with argument.")
  173.     (read get)
  174. )
  175. (info get ((variable integer))
  176.     ("Reads ascii code of next character and unifies it with argument.")
  177.     (read_word read)
  178. )
  179. (info atomic ((anything))
  180.     ("Suceeds if argument is atom or integer or string or real.")
  181.     (atom)
  182. )
  183. (info integer ((anything))
  184.     ("Succeeds if argument type is integer.")
  185.     (atom string atomic)
  186. )
  187. (info string ((anything))
  188.     ("Succeeds if argument type is string.")
  189.     (atom integer atomic )
  190. )
  191.  
  192. /* not implemented
  193. (info real ((anthing))
  194.     ("Succeeds if argument type is real.")
  195.     (atom integer)
  196. )
  197. */
  198. (info atom ((anything))
  199.     ("Succeeds if argument type is atom.")
  200.     (integer string atomic)
  201. )
  202. (info var ((anything))
  203.     ("Succeeds if argument is a variable.")
  204.     (nonvar)
  205. )
  206. (info nonvar ((anything))
  207.     ("Succeeds if argument is not a variable.")
  208.     (var)
  209. )
  210. (info builtin ((atom))
  211.     ("Succeeds if aargument is name of builtin.")
  212. )
  213. (info abort (())
  214.     ("Terminates execution of current query.")
  215.     (quit)
  216. )
  217. (info quit (())
  218.     ("Terminates current session.")
  219.     (abort)
  220. )
  221. (info statistics (())
  222.     ("Displays space left in workspace.")
  223.     ( space_left n_unifications)
  224. )
  225. (info space_left ((var)(var)(var)(var)(var)(var))
  226.     ("Used by statistics.")
  227.     (statistics n_unifications)
  228. )
  229. (info n_unifications ((integer variable))
  230.     ("Unifies argument with number of unifications performed in session.")
  231.     (statistics)
  232. )
  233. (info iplus ((integer)(integer)(variable integer))
  234.     ("Unifies third argument with sum of first two.")
  235.     (iminus imult)
  236. )
  237. (info iminus ((integer)(integer)(variable integer))
  238.     ("Unifies third argument with difference of first two.")
  239.     (iminus imult)
  240. )
  241. (info imult ((integer)(integer)(variable integer))
  242.     ("Unifies third argument with product of first two.")
  243.     (iminus imult)
  244. )
  245. (info iless ((integer)(integer))
  246.     ("Suceeds if first argument is less than second.")
  247.     (rless)
  248. )
  249. (info ileq ((integer)(integer))
  250.     ("Suceeds if first argument is less than or equal to second.")
  251.     (iless)
  252. )
  253. (info rless ((real)(real))
  254.     ("Suceeds if first argument is less than second.")
  255.     (iless)
  256. )
  257. (info rplus ((real)(real)(variable real))
  258.     ("Unifies 3rd argument with sum of first two.")
  259.     (iplus)
  260. )
  261. (info var_offset ((var)(var integer))
  262.     ("Unifies 2nd argument with occurence index of first argument."
  263.      "This is special, see xread.spr.")
  264.     (var_name)
  265. )
  266. (info var_name ((var)(var string))
  267.     ("Unifies 2nd argument with name of first argument."
  268.      "This must be called just after a parse."
  269.      "This is a special predicate, see xread.spr."
  270.     )
  271.     (var_offset)
  272. )
  273. (info clean_temp (())
  274.     ("Clears the temporary zone.")
  275.     (statistics temp_asserta temp_assertz)
  276. )
  277. (info asserta ((list))
  278.     ("Adds a new clause corresponding to first argument."
  279.      "The clause becomes the first of its predicate."
  280.     )
  281.     (assertz temp_asserta temp_assertz remove_clause)
  282. )
  283. (info asserta ((list)(integer))
  284.     ("Adds a new clause corresponding to first argument."
  285.      "Tries to make the clause the nth of its predicate "
  286.      "where n is the value of the second argument.")
  287.     (assertz temp_asserta temp_assertz remove_clause)
  288. )
  289. (info temp_asserta ((list))
  290.     ("Adds a new clause corresponding to first argument."
  291.      "The clause becomes the first of its predicate."
  292.      "The clause is put in the temporary zone."
  293.     )
  294.     (assertz temp_asserta temp_assertz remove_clause clean_temp)
  295. )
  296. (info temp_asserta ((list)(integer))
  297.     ("Adds a new clause corresponding to first argument."
  298.      "The clause is put in the temporary zone."
  299.      "Tries to make the clause the nth of its predicate "
  300.      "where n is the value of the second argument.")
  301.     (assertz temp_asserta temp_assertz remove_clause)
  302. )
  303. (info assertz ((list))
  304.     ("Adds a new clause corresponding to first argument."
  305.      "The clause becomes the last of its predicate."
  306.     )
  307.     (asserta temp_asserta temp_assertz remove_clause)
  308. )
  309. (info temp_assertz ((list))
  310.     ("Adds a new clause corresponding to first argument."
  311.      "The clause becomes the last of its predicate."
  312.      "The clause is put in the temporary zone."
  313.     )
  314.     (asserta temp_asserta assertz remove_clause clean_temp)
  315. )
  316. (info remove_clause ((clause))
  317.     ("Removes the clause."
  318.      "Dont put a list as an argument!"
  319.     )
  320.     (first_clause next_clause body_clause clause retract)
  321. )
  322. (info first_clause ((atom)(variable))
  323.     ("Unifies the 2nd argument with the 1st clause of first argument.")
  324.     (next_clause)
  325. )
  326. (info next_clause ((clause)(variable))
  327.     ("Unifies the 2nd argument with the clause following first argument.")
  328.     (first_clause)
  329. )
  330. (info body_clause ((clause)(list variable))
  331.     ("Unifies the 2nd argument with the body of the 1st argument.")
  332.     (first_clause predicate)
  333. )
  334. (info string_from ((anything)(string variable))
  335.     ("Tries to unify 2nd argument with string representation of "
  336.      "first argument.")
  337.     (string_length interned)
  338. )
  339. (info interned ((string)(variable))
  340.     ("Succeeds if string has corresponding atom."
  341.      "Unifies the variable with the atom in this case."
  342.      )
  343.     (string_from)
  344. )
  345. (info string_length ((string)(variable integer))
  346.     ("Unifies 2nd argument with length of first argument.")
  347.     (string_nth)
  348. )
  349. (info string_nth ((integer)(string)(variable integer))
  350.     ("Unifies 3rd argument with ascii code of nth char of 2nd argument.")
  351.     (string_length)
  352. )
  353. (info string_concat ((string)(string)(variable string))
  354.     ("Unifies 3rd argument with concatenation of the first two arguments.")
  355.     (string_length string_nth)
  356. )
  357. (info string_suffix ((integer)(string)(string variable))
  358.     ("Unifies 3rd argument with rest of string of first string "
  359.     "from nth character on -where n is the value of first argument.")
  360.     (string concat)
  361. )
  362. (info rand ((integer variable)(integer))
  363.     ("Unifies first argument with a pseudo-random integer "
  364.      "less than second argument."
  365.      "Not very random (not my fault!)."
  366.     )
  367.     ()
  368. )
  369.  
  370. (info listing (())
  371.     ("Displays all clauses in workspace.")
  372.     (statistics logging)
  373. )
  374. (info  listing ((atom))
  375.     ("Displays all clauses correponding to argument.")
  376.     (statistics)
  377. )
  378. (info fail (())
  379.     ("The recommended way of deliberately failing")
  380.     ()
  381. )
  382. (info repeat (())
  383.     ("Create a backtrack point that never stops")
  384.     (fail cut)
  385. )
  386.  
  387. (info gennum ((variable integer)(integer))
  388.     ("Unify 1st argument with integers from 0 to 2nd argument"
  389.      "through backtracking (try (gennum X 3))"
  390.     )
  391.     (fail cut)
  392. )
  393.  
  394. (info logging ((string))
  395.     ("Records the session from then on to named file.")
  396.     (nologging)
  397. )
  398. (info nologging (())
  399.     ("Stops logging the session.")
  400.     (logging)
  401. )
  402.  
  403. (info not ((list))
  404.     ("Succeeds iff argument fails as goal.")
  405.     (diff)
  406. )
  407. (info diff ((anything)(anything))
  408.     ("Succeeds if arguments are different."
  409.      "Arguments should not have variables."
  410.     )
  411.     (not)
  412. )
  413. (info eq ((anything)(anything))
  414.     ("Suceeds if arguments can be unified."
  415.      "Most beginners use this where they need not.")
  416.     (diff)
  417. )
  418. (info member ((anything)(list))
  419.     ("succeeds if 1st argument can be unified with a member of 2nd argument.")
  420.     (append)
  421. )
  422. (info append ((list variable)(list variable)(list variable))
  423.     ("Succeeds if you can unify the concatenation of the first 2 arguments"
  424.      "with the third argument")
  425.     (member)
  426. )
  427. (info all_facts ((list)(variable list))
  428.     ("Unifies 2nd argument with list of all facts "
  429.      "having same predicate as 1st argument."
  430.     "Can be an alternative to findall."
  431.     )
  432.     (findall)
  433. )
  434. (info findall ((variable list)(list)(variable list))
  435.     ("Unifies 3rd argument with list of all elements matching"
  436.      "first argument such that second argument succeeds as goal."
  437.      "Not space efficient due to lack of garbage collector."
  438.      "See example file.")
  439.     (all_facts)
  440. )
  441. (info clause ((list)(list))
  442.     ("Unifies 1st argument with head of existing clauses "
  443.      "and 2nd argument with conditions of corresponding clause.")
  444.     (predicate)
  445. )
  446. (info predicate ((atom variable))
  447.     ("Unifies 1st argument with non-builtin predicates.")
  448.     (builtin)
  449. )
  450. (info retract ((list))
  451.     ("Removes fact corresponding to list."
  452.      "Can backtrack, removing all such facts."
  453.     )
  454.     (remove_clause)
  455. )
  456. (info and (list)
  457.     ("This has a variable number of arguments."
  458.      "Only Micro-prolog and Small Prolog give you this."
  459.      "Succeeds if all arguments succeed as goals."
  460.      "Useful in intricate logical expressions."
  461.     )
  462.     (or)
  463. )
  464. (info or (list)
  465.     ("This has a variable number of arguments."
  466.      "Only Micro-prolog and Small Prolog give you this."
  467.      "Succeeds if one of the arguments succeeds as a goal."
  468.      "Useful in intricate logical expressions."
  469.     )
  470.     (or)
  471. )
  472. (info cut (())
  473.     ("Stop looking for solutions of parent goal."
  474.       "See any good book for more."
  475.     )
  476.     (fail)
  477. )
  478. (info trace (())
  479.     ("Turns tracing mode on.")
  480.     (notrace suspend_trace resume_trace)
  481. )
  482. (info notrace (())
  483.     ("Turns tracing mode off.")
  484.     (trace suspend_trace resume_trace)
  485. )
  486. (info reverse_trace_mode (())
  487.     ("Turns reverse tracing mode on."
  488.      "this does not turn tracing on by its own"
  489.      "but it is necessary it you want to be able to reverse trace"
  490.     )
  491.     (trace notrace suspend_trace resume_trace no_reverse_trace_mode)
  492. )
  493. (info no_reverse_trace_mode (())
  494.     ("Turns reverse tracing mode off."
  495.      "This reverts the system back to the default mode."
  496.     )
  497.     (trace notrace suspend_trace resume_trace reverse_trace_mode)
  498. )
  499. (info suspend_trace (())
  500.     ("Decrements the trace_flag that is responsible for tracing."
  501.      "This is useful in the bodies of rules whose executions you trust.")
  502.      (resume_trace trace notrace)
  503. )
  504. (info resume_trace (())
  505.     ("Increments the trace_flag that is responsible for tracing.")
  506.      (suspend_trace trace notrace )
  507. )
  508.