See the references at the end of this post for details related with this topic. It will help you learn all the nuts and bolts of streams handling in clisp.
Now I want to read this file which contain following information. To be precise, its a graph written in a format which resembles lisp code.
(a) (b c d) (b) (a c d) (c) (a b d) (d) (b c)
It graph file can be very complicated. Here is what I did to read this file. What each line does in code can be googled out easily. Just put lisp with the keyword while searching.
; Dilawar Singh ; 2011, IIT Bombay ; Dept of Electrical Engineering. ;; This function will open a file and read a graph. ;; TODO : Graph Format. ;; ;;; THIS SECTION OPEN A FILE AND READ IT. ;;;; TODO: File name should be passed from terminal. For now we assume that file ;;;; name is 'graph.txt' by dafault and it reside is the same directory as of this ;;;; file containing source code. (with-open-file (graph-stream "./graph.txt" :direction :input :if-does-not-exist :create) (loop for line = (read-line graph-stream nil 'end-of-graph) until(eq line 'end-of-graph) do( print line))) ;; We need to something more.