1
0
mirror of https://github.com/PDP-10/its.git synced 2026-04-05 13:41:09 +00:00
Files
PDP-10.its/doc/wiki/its_lisp

112 lines
4.2 KiB
Plaintext

<p>
<strong>PDP-10 Maclisp</strong>
</p>
<p>
The ITS Lisp is called Maclisp, or PDP-10 Maclisp if necessary to disambiguate it against <a href="/doku.php?id=multics_maclisp" class="wikilink1" title="multics_maclisp">Multics Maclisp</a>. Its direct ancestor is <a href="/doku.php?id=its_pdp6_lisp" class="wikilink1" title="its_pdp6_lisp">PDP-6 LISP</a>.
</p>
<p>
<strong>A sample MACLISP session on ITS using LEDIT MODE in EMACS</strong>
<em>LEDIT will work on both <a href="/doku.php?id=its_topics" class="wikilink1" title="its_topics">ITS</a> and <a href="/doku.php?id=tops-20" class="wikilink1" title="tops-20">TOPS-20</a> ;tnx1.0e6 to GLS</em>
</p>
<pre class="code">
KA ITS 1648 DDT 1547 TTY 52 ;System herald
:login smith ;The luser logs in
:lisp ;MACLISP is started
LISP 2154 ;MACLISP version
ALLOC? N ;Take the world defaults
(plus 3.14 2.71) ;Add two numbers
5.85
(car &#039;(simple list)) ;Return the CAR of a LIST
SIMPLE
(ledit) ;Enters EMACS in LEDIT MODE
(defun sum-squares (a b) ;Typed into the EMACS buffer
(plus (times a a
(times b b)))) ;META-Z pushes DEFUN to the world
;CTRL-X Z returns to LISP
;READING FROM LEDIT SUN-SQUARES ;Back in LISP
;EDIT COMPLETED
(sum-squares 2.0 3.0) ;call SUM-SQUARES
36.0 ;Returns the wrong number
(ledit) ;Re-enter EMACS in LEDIT MODE
CTRL-S (times a a ;Typed into EMACS
;Search for STRING (times a a
(defun sum-squares (a b) ;Correct SUM-SQUARES
(plus (times a a)
(times b b))) ;META-Z pushes new DEFUN to world
;CTRL-X Z returns to LISP
;READING FROM LEDIT SUM-SQUARES ;Back in LISP
;EDIT COMPLETED
(sum-squares 2.0 3.0) ;Call SUM-SQUARES again
13.0 ;Correct result</pre>
<p>
<em>The LISP … Editor … LISP … loop will no doubt be repeated many times.</em>
</p>
<p>
<strong>HELLO WORLD and LOOP examples</strong>
</p>
<pre class="code"> @maclisp ; start MACLISP at the TOPS-20 EXEC
LISP 2122 ; MACLISP Version 2122
Alloc? n ; take the defaults
*
(defun HELLO () ; DEFINE FUNCTION &quot;HELLO&quot;
(princ &quot;Hello World!&quot;)) ; print characters &quot;Hello World!&quot;
HELLO ; MACLISP reports a definition for the function &quot;HELLO&quot;
(hello)Hello World! ; The function &quot;HELLO&quot; is called and &quot;Hello World!&quot; is printed
T ; MACLISP reports T for a successful function call</pre>
<pre class="code"> @maclisp
LISP 2122
Alloc? n
*
(loop for x in &#039;(a b c d e) ; Call the macro &quot;LOOP&quot; for VARIABLE &quot;x&quot; in a list of &quot;a b c d e&quot;
do (print x)) ; DO a PRINT of the value of &quot;x&quot;
;Loading LOOP 725 ; MACLISP loads LOOP version 725
;Loading DEFMAX 98 ; MACLISP loads DEFMAX version 98
A ; 1. X = A
B ; 2. X = B
C ; 3. X = C
D ; 4. X = D
E ; 5. X = E
NIL ; DO called PRINT X which returned NIL because there was nothing
; left to PRINT in the list of &quot;a b c d e&quot;</pre>
<p>
<strong>MATH examples</strong>
</p>
<pre class="code"> @maclisp
LISP 2122
Alloc? n
*
(+ 2 2)
4
(- 2 2)
0
(* 2 2)
4</pre>