2.2 Sample Lisp program

2.2.2 Terminal session

This sample terminal session shows how the program file"queue.lisp" is loaded into Lisp. Once loaded, the functions defined in the file can be called in the current Lisp environment. This session illustrates the interactive nature of programming in Lisp.

;; Load the code that implements queues.
> (load "queue")
;;; Loading source file "queue.lisp"
#P"queue.lisp"
;; Create a queue.
>  (setq q1 (make-queue))
#<Queue 0/100 630E93>

;; Put an element into the queue. > (queue-put q1 :theta) T

;; Put a second element into the queue. > (queue-put q1 :iota) T

;; Retrieve the first element. > (queue-get q1) :THETA

;; Retrieve the next element. > (queue-get q1) :IOTA

;; Try to retrieve something from an empty queue. > (queue-get q1) NIL

;; Try to retrieve something from an empty queue, but this time ;; specify an empty marker. > (queue-get q1 'none) NONE

;; Put something into the queue. > (queue-put q1 :kappa) T

;; Now use SETF to put some elements into the queue. > (setf (queue-get q1) :lambda) T

> (setf (queue-get q1) :mu) T

;; The queue now has three elements in it. > q1 #<Queue 3/100 630E93>

;; Exit Lisp and return to the operating system. > (quit) %


The User's Guide - 9 SEP 1996

Generated with Harlequin WebMaker