I am newcomer in Lisp and still confusing with programming even basic.
I tried to program to compute the < the transitive closure of R>
< the reflective closure of R>
The R is relation R=T *T given by a list of pairs
e.g.R=((a,b)(a,c)(d,e)(c,e))
T is a set of symbols.
The follwoing is < the transitive closure of R>
; Programs
(
defun val (f s)
(setq flist f)
(setq nlist '())
(loop
(setq cc (pop flist) )
(cond ((assoc (cadr cc) s)
(push (list (car cc) (cadr (assoc (cadr cc) s))) nlist)
)
(t (push cc nlist))
)
(if (endp flist) (return))
)
(print(reverse nlist))
)
(defun tal (f s)
(setq slist s)
(setq nlist2 '())
(loop
(setq tt (pop slist))
(cond ((assoc (car tt) f) (setq a 1))
(t (push tt nlist2))
)
(if (endp slist) (return))
)
(print(reverse nlist2))
)
(defun total(f s)
(print 'input)
(print f)
(print s)
(print 'output)
(val f s)
(tal f s)
(print 'end)
)
; test inputs
(total '((a,b)(a,c)(d,e)(c,e)))
somethings like weird to me . I don't know where I should change to
match the requirement given above.
If possible, can you give me some hints on reflective of closure R.
Thanks
Colette