; -*- Mode: Lisp; Package: GPSG; Base: 10; Syntax: Common-Lisp -*-
; (in-package 'gpsg :use '(lisp))

(defun list-hash-table (hash-table)
  (let ((result nil))
    (maphash #'(lambda (key val) (push (list key val) result)) hash-table)
    result))

(defun listify (sent)
  (if (listp sent) sent
      (read-from-string
	(concatenate 'string "(" sent ")"))))

(defvar v-p t)

(defun msg (&rest data)
  (if v-p (if (stringp (car data)) ; Forgot to give stream
	      (apply #'format (cons 't data))
	      (apply #'format data))))
(defun verbose ()
  (setq v-p (not v-p))
  v-p)

(defun and-list (list)
  (cond ((null list) t)
	((car list) (and-list (cdr list)))
	(t nil)))

(defun or-list (list)
  (cond ((null list) nil)
	((car list) t)
	(t (or-list (cdr list)))))

(defun s< (a b)
  (let ((sa (cond ((stringp a) (subseq a 0 (position #\space a)))
		  ((symbolp a) (string a))
		  ((symbolp (car a)) (string (car a)))
		  (t (string (caar a)))))
	(sb (cond ((stringp b) (subseq b 0 (position #\space b)))
		  ((symbolp b) (string b))
		  ((symbolp (car b)) (string (car b)))
		  (t (string (caar b))))))
    (string< sa sb)))
