Lisp is a very unusual language.  It is the second oldest programming language still in use today.  Lisp is short for List Processing.  Everything in Lisp is represented as a list.  To add three numbers, you would use a construct like this (+ 3 4 5).  This is a list with 4 elements: the operator + and 3 numbers to be added together.  Lists are often nested. (sqrt (+ (expt x 2) (expt y 2))) is the Pythagorean formula sqrt(x^2 + y^2).

The code below was tested using Clisp.

maze.lisp


;;;globals to hold width and height of maze
(setf *random-state* (make-random-state t))

(format t "~&Width? ")
(defvar WIDTH (read)) ;input width from console
(format t "~&Height? ")
(defvar HEIGHT (read)) ;input height from console

;;; the cell structure, north, south, east, west -> t = path, nil = wall
(defstruct cell
	(position '(0 0))
	(north nil)
	(south nil)
	(east nil)
	(west nil)
	(visited nil))
	
;;; the array of cells,	
(setf maze (make-array (list HEIGHT WIDTH)))

;;; this function takes a cell as input and returns a list of valid directions
;;; i.e. not across border, not visited
(defun get-valid-directions (cell)
	(let ((directions nil)
		 (position (cell-position cell)))
		(if (and (> (first position) 0) (not (cell-visited (aref maze (- (first position) 1) (second position)))))
			(push 0 directions))
		(if (and (< (second position) (- WIDTH 1)) (not (cell-visited (aref maze (first position) (+ (second position) 1)))))
			(push 1 directions))
		(if (and (< (first position) (- HEIGHT 1)) (not (cell-visited (aref maze (+ (first position) 1) (second position)))))
			(push 2 directions))
		(if (and (> (second position) 0) (not (cell-visited (aref maze (first position) (- (second position) 1)))))
			(push 3 directions))
		directions))

;;; fill the array with cells
(dotimes (column WIDTH)
	(dotimes (row HEIGHT)
		(setf new-cell (make-cell))
		(setf (cell-position new-cell) (list row column))
		(setf (aref maze row column) new-cell)))

;;; our stack for the recursive-backtracker algorythm.
(setf stack nil)

;;; pick a cell at random and place it on the stack
(setf current-cell (aref maze (random HEIGHT) (random WIDTH)))
(setf (cell-visited current-cell) t)
(push current-cell stack)
;;; repeat until the stack is empty
(do ((current-cell (first stack) (first stack)))
	((null stack))
	(let  ((directions (get-valid-directions current-cell))
			(position (cell-position current-cell))
			(direction 0)
			(chosen-cell nil))
	(cond ((= (length directions) 0)
			(pop stack))
		(t (setf direction (nth (random (length directions)) directions))
			(cond ((= direction 0)
					(setf chosen-cell (aref maze (- (first position) 1) (second position)))
					(setf (cell-north current-cell) t)
					(setf (cell-south chosen-cell) t)
					(setf (cell-visited chosen-cell) t))
				((= direction 1)
					(setf chosen-cell (aref maze (first position) (+ (second position) 1)))
					(setf (cell-east current-cell) t)
					(setf (cell-west chosen-cell) t)
					(setf (cell-visited chosen-cell) t))
				((= direction 2)
					(setf chosen-cell (aref maze (+ (first position) 1) (second position)))
					(setf (cell-south current-cell) t)
					(setf (cell-north chosen-cell) t)
					(setf (cell-visited chosen-cell) t))
				((= direction 3)
					(setf chosen-cell (aref maze (first position) (- (second position) 1)))
					(setf (cell-west current-cell) t)
					(setf (cell-east chosen-cell) t)
					(setf (cell-visited chosen-cell) t)))
			(push chosen-cell stack)))))
			
;;;print the maze :):):):)
(format t "~&+")
(dotimes (column WIDTH)
	(format t "--+"))
(dotimes (row HEIGHT)
	(format t "~&|")
	(dotimes (column WIDTH)
		(if (equal (cell-east (aref maze row column)) t)
			(format t "   ")
			(format t "  |")))
	(format t "~&+")
	(dotimes (column WIDTH)
		(if (equal (cell-south (aref maze row column)) t)
			(format t "  +")
			(format t "--+"))))