home *** CD-ROM | disk | FTP | other *** search
/ CBM Funet Archive / cbm-funet-archive-2003.iso / cbm / c64 / programming / mlisp.sfx / mlisp.cmds < prev    next >
Encoding:
Text File  |  1993-09-09  |  12.6 KB  |  412 lines

  1.   This is a list of Micro-Lisp 2.5 built in functions as published in the article by Nicholas Vrtis in the Transactor vol.8 no.6.
  2.  
  3.                                         ABORT     (ABORT msg)
  4.  
  5. Stops current processing, displays the message that msg evaluates to, and returns to the top level of processing.  This function can be used to define additional error processing.
  6.  
  7.  
  8. ABS       (ABS n)
  9.  
  10. Returns the absolute valaue of n.
  11.  
  12.  
  13. ADD       (ADD n1 ... nn)
  14.  
  15. Returns the sum of the numbers n1 through nn.
  16.  
  17.  
  18. AND       (AND x1 ... xn)
  19.  
  20. Evaluates x1 and, if it is not nil, proceeds to evaluate the following arguments until nil is returned, or the end of the argument List is encountered.  Not that AND does not evaluate the following arguments if nil is returned from any argument.
  21.  
  22.  
  23. APPEND    (APPEND l1 l2)
  24.  
  25. Returns the List created by appending l2 to the end of l1.
  26.  
  27.  
  28. APURGE    (APURGE atm)
  29.  
  30. Purges the Atom atm from memory and frees the space for re-use.  Any references to atm in Lists are changed to reference nil.  APURGE removes the value, definition, and property Lists of built-in functions, but does not remove the built-in definition or free the space.
  31.  
  32.  
  33. ATOM      (ATOM x)
  34.  
  35. Returns t (true) if x evaluates to an Atom; returns nil otherwise.
  36.  
  37.  
  38. BAKTRACK  (BAKTRACK n)
  39.  
  40. Displays the last n functions that were executed.  Only valid if debug has been previously activated (see setdebug).
  41.  
  42.  
  43. CAR       (CAR list)
  44.  
  45. Returns the first part of list.
  46.  
  47.  
  48. CDR       (CDR list)
  49.  
  50. Returns the rest of list after the first part (the car) is skipped.
  51.  
  52.  
  53. COLD      (COLD)
  54.  
  55. Restarts Micro-Lisp from the beginning.  All options and parameters are reset to the way they were when RUN was issued.
  56.  
  57.  
  58. COND      (COND (t1 r1)(t2 r2))
  59.  
  60. Evaluates t1 and executes r1.  If t1 returns non-nil, cond proceeds to evaluate t2.  Note that t2 will not be evaluated if t1 does not evaluate to nil.  An error is issued if all tests evaluate to nil.
  61.  
  62.  
  63. CONS      (CONS x1 x2)
  64.  
  65. Returns a List that has x1 as its first part (car) and x2 as its rest part (cdr).  If x1 and x2 evaluate to Atoms, a special List called a 'Dotted Pair' is returned.
  66.  
  67.  
  68. DECIMAL   (DECIMAL)
  69.  
  70. Sets the current number base to decimal and returns the number 10.
  71.  
  72.  
  73. DEFINE    (DEFINE fn arg x)
  74.  
  75. Create a function called fn that has arguments specified in the list arg.  The body of the function is specified in the list x.  In define, fn, arg, and x are evaluated.  A defined function has an implied progn before the body.
  76.  
  77.  
  78. DEFUN     (DEFUN fn arg x)
  79.  
  80. Same as define, except that fn, arg, and x are not evaluated.  It is a more convenient form when entering a function since quotes are not needed.
  81.  
  82.  
  83. DISKCMD   (DISKCMD msg)
  84.  
  85. Issues the disk command msg.  This function opens and closes the disk command channel.
  86.  
  87.  
  88. DISKST    (DISKST)
  89.  
  90. Reads the disk status via the command channel.  The function opens and closes the command channel.
  91.  
  92.  
  93. DISK$     (DISK$)
  94.  
  95. Reads the disk directory and returns a List of Lists about the disk.  Each entry is a List of 3 Atoms.  The first Atom is the number of blocks, the second is the file name, and the third is the file type.  The first entry is the disk name, and the last entry is the number of blocks.
  96.  
  97.  
  98. DIVIDE    (DIVIDE n1 n2)
  99.  
  100. Returns the integer result of n1 divided by n2.
  101.  
  102.  
  103. DOUNTIL   (DOUNTIL t x1 ... xn)
  104.  
  105. A looping function.  The test t is evaluated and, until it is true (non-nil), the expressions x1 through xn are evaluated (using an implied progn).  DOUNTIL returns the non-nil value returned from the expression t.
  106.  
  107.  
  108. DOWHILE   (DOWHILE t x1 ... xn)
  109.  
  110. A looping function.  The test t is evaluated and, while it is still true (non-nil), the expressions x1 through xn are evaluated (using an implied progn).  DOWHILE returns nil always.
  111.  
  112.  
  113. EDIT      (EDIT)
  114.  
  115. Exits Lisp to the BASIC screen editor.  You may enter a Lisp program as you would a BASIC program.  The only keywords that will function are LOAD, SAVE, LIST, NEW, and END.  END returns you back to Micro-Lisp, the others operate as expected.
  116.  
  117.  
  118. EQ        (EQ x1 x2)
  119.  
  120. Returns t if x1 is identical to x2.  Not very useful if comparing Lists.
  121.  
  122.  
  123. EQUAL     (EQUAL x1 x2)
  124.  
  125. Returns t if x1 is the same as x2, otherwise returns nil.  This will properly test Lists.
  126.  
  127.  
  128. EVAL      (EVAL x)
  129.  
  130. Evaluates the List that x evaluates to.  (Eval'(car'(a b))) will produce the same results as (car'(a b)).
  131.  
  132.  
  133. EXIT      (EXIT)
  134.  
  135. Leaves Lisp and returns to BASIC.
  136.  
  137.  
  138. EXPLODE   (EXPLODE a)
  139.  
  140. Returns a List of numbers that represent the ASCII value of thename of the Atom a.  If a evaluates to a number, it is converted according to the current base and the ASCII values of the digits are returned.
  141.  
  142.  
  143. GC        (GC)
  144.  
  145. Forces a garbage collection to take place.  Returns t.
  146.  
  147.  
  148. GETDEF    (GETDEF a)
  149.  
  150. Returns the definition of the function specified by a.  Returns nil if a has not been previously defined.
  151.  
  152.  
  153. GETPROP   (GETPROP a pn)
  154.  
  155. Returns the property value stored under the property name pn under the atom a.  Returns nil if pn is not defined under a.
  156.  
  157.  
  158. GREATERP  (GREATERP n1 ... nn)
  159.  
  160. Returns t if the numbers n1 through nn are in descending order.  Note that equal is not considered descending.
  161.  
  162.  
  163. HEX       (HEX)
  164.  
  165. Set the current number conversion base to 16 (hexadecimal).  Returns the value 10 hex (decimal 16).
  166.  
  167.  
  168. IMPLODE   (IMPLODE l)
  169.  
  170. Takes a List of numbers representing ASCII characters and returns an Atom whose print name is that series of ASCII characters.  If any number is greater than 256, the ASCII character is taken from the MOD 256 value.  If the print name resulting from imploding the List results in a valid number, then it will be converted to a number.
  171.  
  172.  
  173. LAMBDA    ((LAMBDA (x) (b)) y)
  174.  
  175. A method of executing a function without defining it.  The current value of x is saved, then it is assigned the value of y and the body b is evaluated (with an implied progn).  After b is evaluated, x is restored to its previous value.  Note that there may be more than one Atom specified in the argument list, and that there must be a one to one correspondence between the number of arguments and the number of values supplied.
  176.  
  177.  
  178. LENGTH    (LENGTH x)
  179.  
  180. Returns the number of elements in the List x.
  181.  
  182.  
  183. LESSP     (LESSP n1 ... nn)
  184.  
  185. Returns t if the numbers n1 through nn are in ascending order.  Note that equal is not considered ascending.
  186.  
  187.  
  188. LIST      (LIST x1 ... xn)
  189.  
  190. Returns a List containing x1 through xn.
  191.  
  192.  
  193. LISTP     (LISTP x)
  194.  
  195. Returns t if x evaluates to List, nil if x evaluates to an Atom.
  196.  
  197.  
  198. LOAD      (LOAD fn)
  199.  
  200. Loads a previously saved environment from file fn.  This must be executed from the first level.
  201.  
  202.  
  203. LPAREN    (LPAREN)
  204.  
  205. Outputs the left parenthesis character.
  206.  
  207.  
  208. MEM       (MEM)
  209.  
  210. Prints out the number of the object entries, the number of free List entries and the amount of unallocated memory (in bytes).  Returns the amount of unallocated memory.
  211.  
  212.  
  213. MULTIPLY  (MULTIPLY n1 ... nn)
  214.  
  215. Returns the product of n1 times n2 ... times nn.  Note that no check is made for overflow.
  216.  
  217.  
  218. NEW       (NEW)
  219.  
  220. Clears memory of any user defined Atoms, Lists, and functions without changing settings such as pretty print, echo or number base.
  221.  
  222.  
  223. NIL       NIL, (NIL), or ()
  224.  
  225. This is the Lisp specification of 'nothing'.  As a value it returns nil; as a function is also returns nil.  It is also considered both an Atom and a List.
  226.  
  227.  
  228. NTH       (NTH n l)
  229.  
  230. Returns the nth element in List l.
  231.  
  232.  
  233. NULL      (NULL x)
  234.  
  235. Returns t if x evaluates to nil, returns nil otherwise (performs a logical NOT function).
  236.  
  237.  
  238. NUMBERP   (NUMBERP x)
  239.  
  240. Returns t if x evaluates to a number, nil otherwise.
  241.  
  242.  
  243. OR        (OR x1 ... xn)
  244.  
  245. Evaluates x1 and if it is nil, OR proceeds to evaluate the following arguments until a non-nil value is returned, or the end of the argument list is encountered.  Note that OR does not evaluate the following arguments if non-nil is returned from any argument.
  246.  
  247.  
  248. PATOM     (PATOM a)
  249.  
  250. Prints the Atom a.
  251.  
  252.  
  253. PRINT     (PRINT x)
  254.  
  255. Prints the expression x evaluates to, followed by a carriage return.  PRINT returns the value t.  If the pretty print flag is set, each parenthesis level will be started on a new line, and will be indented.
  256.  
  257.  
  258. PROGN     (PROGN (x1) ... (xn))
  259.  
  260. Successively evaluates the specified function expressions, x1 through xn.
  261.  
  262.  
  263. PUTPROP   (PUTPROP a pn pv)
  264.  
  265. Puts the property value pv as the property pn of Atom a.  If the property already exists, the old value is replaced by the new value.
  266.  
  267.  
  268. QUOTE     (QUOTE x)
  269.  
  270. Returns the unevaluated expression x.
  271.  
  272.  
  273. RATOM     (RATOM)
  274.  
  275. Waits for a single Atom to be entered from the terminal.
  276.  
  277.  
  278. READ      (READ)
  279.  
  280. Reads an expression from the terminal.
  281.  
  282.  
  283. RPAREN    (RPAREN)
  284.  
  285. Outputs a right parenthesis to the terminal.
  286.  
  287.  
  288. SAVE      (SAVE fn)
  289.  
  290. Saves the current environment (including all objects and Lists to file fn.
  291.  
  292.  
  293. SET       (SET a x)
  294.  
  295. Causes the value of x to be assigned to the Atom a.
  296.  
  297.  
  298. SETBASE   (SETBASE n)
  299.  
  300. Sets the number base used for conversion for both input and output.  Note that n is converted and evaluated with the current base before the new number base is set.
  301.  
  302.  
  303. SETDEBUG  (SETDEBUG x)
  304.  
  305. If x evaluates to nil, debug mode is turned off; if it evaluates to non-nil, debug mode is turned on.  Debug mode is useful for problem determination.  If debug mode is son, Micro-Lisp will track up to the last 128 functions.  This tracking can be reviewed using the BAKTRACK function.  Unlike TRACE, which displays the actual input arguments to a function, DEBUG only tracks the unevaluated arguments.  Debug mode also gives you an opportunity to print any Atom values before LAMBDA and function arguments are restored in error processing.  This is sometimes useful in determining what caused an error condition to occur.
  306.  
  307.  
  308. SETECHO   (SETECHO x)
  309.  
  310. Used to control the echo of source input to the terminal.  (SETECHO t) will cause all source input to be echoed (this is the default setting).  (SETECHO nil) will eliminate the echo.
  311.  
  312.  
  313. SETPRETTY (SETPRETTY x)
  314.  
  315. Used to set the pretty print flag.  If x is non-nil, pretty printing will be turned on and expressions will be printed with each parenthesis on a new line and indented for easier reading.  If x is nil, the flag is turned off.
  316.  
  317.  
  318. SETQ      (SETQ a x)
  319.  
  320. Causes the value of x to be assigned to Atom a (similar to SET, except that for SETQ, a is not evaluated).
  321.  
  322.  
  323. SOURCE    (SOURCE fn)
  324.  
  325. Directs that input is to come from the disk file fn instead of the keyboard.  Input is obtained from there until the end of the source file.  The source file may contain another SOURCE statement.  This will close the current source file and open the new source file for input.
  326.  
  327.  
  328. SUBTRACT  (SUBTRACT n1 n2)
  329.  
  330. Returns the value of n1 - n2.
  331.  
  332.  
  333. SYS       (SYS adr x y a f)
  334.  
  335. Invokes a machine language routine at address adr.  The values for the x, y, a and f (flag) registers are optional and specified by the corresponding arguments.  This function will not allow the IRQ flag to be set, but any other processor flags can be set with the f argument.  This function returns a List of numbers consisting of the values of the X, Y, A and FLAG registers after the return from the machine code call.
  336.  
  337.  
  338. T         T, (T)
  339.  
  340. T is one method of specifying a non-nil value.  As a function, T returns t.
  341.  
  342.  
  343. TERPRI    (TERPRI)
  344.  
  345. Causes a carriage return to be output.
  346.  
  347.  
  348. TRACE     (TRACE x)
  349.  
  350. Causes each function level and its arguments to be output to the terminal as it is evaluated.  Note that the actual evaluated arguments are output.
  351.  
  352.  
  353. UNDEF     (UNDEF a)
  354.  
  355. Removes the function definition from the Atom a.  If a was a native function that had been redefined, the native definition will be restored.
  356.  
  357.  
  358. ZEROP     (ZEROP n)
  359.  
  360. Returns t if n is equal to zero; returns nil if it is not.
  361.  
  362.  
  363. +         (+ n1 ... nn)
  364.  
  365. Shorthand for ADD.
  366.  
  367.  
  368. -         (- n1 n2)
  369.  
  370. Shorthand for SUBTRACT.
  371.  
  372.  
  373. *         (* n1 ... nn)
  374.  
  375. Shorthand for MULTIPLY.
  376.  
  377.  
  378. /         (/ n1 n2)
  379.  
  380. Shorthand for DIVIDE.
  381.  
  382.  
  383.  
  384. Special Input Characters
  385. ------------------------
  386. ^ - Used to start and end a comment.  All characters between the first and second ^ are ignored.  (Note: this character prints on your C64 screen as an up arrow).
  387.  
  388.  
  389. ' - Used as shorthand for (quote ...).  (quote x) can be shortened to 'x.  Note the dropping of the word QUOTE and a set of parentheses.  'X will print out as (quote x).
  390.  
  391.  
  392. " - Used to allow special characters and spaces to be included in an Atom name.  Any characters between the double-quotes will become part of the Atom name.  The double-quotes themselves will not become part of the name.
  393.  
  394.  
  395. $ - Used to specify a base 16 (hex) number regardless of the current setting of base.  Must precede any digits.
  396.  
  397.  
  398. . - Used to specify a base 10 (decimal) number regardless of the current setting of base.  Must precede any digits.
  399.  
  400.  
  401. % - Used to specify a base 8 (octal) number regardless of the current setting of base.  Must precede any digits.
  402.  
  403.  
  404.  
  405. Additional Notes
  406. ----------------
  407.  
  408. All numbers are stored as 24-bit signed integers.  This allows a range of +8,388,607 to -8,388,608.
  409.  
  410.  
  411. Cursor control keys work as they do in BASIC.
  412.