From: Yat Hin Chu
Subject: please, ask for help!!!
Date: 
Message-ID: <36C62217.7F727162@hot.mail>
First, thanks for Martti's answer, that is very helpful.  I will get a
better lisp program ASAP.   Could anybody give me a hand here?  Im
currently working on the question which asks us to write a program that
generates N by N crossword puzzles using the depth first search.  I've
already done most of the parts, except for the last function ok, which
tests the condition whether the transpose word is the same as the words
from Dictionary.  If yes, it returns true (I think this is supposed the
way it works, but since i didn't finish this function, so not really
sure about it......)  and the codes i did are as following:
And thankx for the help!!!

(setq word-length 3)
(setq Dict '("aaa" "bbb" "aba"))

(defun transpose-word (L)
  (cond
    ((equal (length (car L)) 0 nil)
    (t (cons(make-string(first-chars L) (transpose-word(trail-chars
L))))))

(defun first-chars (L)
  (cond
    ((equal (length L) 0) nil)
    (t (cons (subseq(car L) 0 1) (first-chars(cdr L))))))

(defun trail-chars (L)
  (cond
    ((null L) nil)
    (t (cons (subseq(car L) 1)
             (trail-chars (cdr L)))))

(defun make-string (L)
   (cond
      ((null L) "")
      (t (concatenate 'string (car L) (make-string (cdr L))))))

(defun search (level solution Dict)
  (do((Rest Dict (cdr Rest))
     ((null Rest) nil)
     (let ((New-sol (append solution (list (car Rest)))))
     (cond
     ((and (OK (transpose-word New-sol))
       (equal level word-length))
       (print New-sol)))
     ((and (OK (transpose-word New-sol))
       (search (+ level 1) New-sol Dict))
     (t nil))))

(defun OK(L)
   (do((Rest Dict (cdr Rest)))
      ((null Rest) nil)
      (cond
      ((equal (car Rest) (car L) t) (OK(cdr L)))
      (t nil))))