;;; -*-LISP-*- ;;; ;;; Copyright (C) 2001 Donald Fisk ;;; ;;; This program is free software; you can redistribute it and/or modify ;;; it under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 2 of the License, or ;;; (at your option) any later version. ;;; ;;; This program is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with this program; if not, write to the Free Software ;;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (load 'utile) (setq *objects* '()) (defun fget (f s) (if (member s '(isa part-of)) (get-ancestors f s) (mapappend (function (lambda (x) (get x s))) (get-ancestors f 'isa)))) (defun fput (f s v) (cond ((member v (get f s)) NIL) (t (putprop f (cons v (get f s)) s) (if (member f *objects*) NIL (setq *objects* (cons f *objects*)))))) (defun fcheck (f s v) (member v (fget f s))) (defun get-ancestors (f s) (do ((parents (list f) (append (cdr parents) (get (car parents) s))) (ancestors '())) ((null parents) (nreverse ancestors)) (setq ancestors (cons (car parents) ancestors)))) (defun query () (do ((q (progn (print '$) (read)) (progn (print '$) (read)))) ((equal q '(bye)) (print '(see you soon))) (cond ((atom q) (print '(what))) ((eq (car q) '+) (fput (cadr q) (caddr q) (cadddr q)) (print '(ok))) ((eq (car q) '-) (print '(not implemented yet))) ((eq (car q) '?) (print (mapappend (function (lambda (x) (if (fcheck x (cadr q) (caddr q)) (list x) '()))) *objects*))) ((eq (caddr q) '?) (print (fget (car q) (cadr q)))) ((fcheck (car q) (cadr q) (caddr q)) (print '(yes))) (t (print '(no))))))