Search found 10 matches

by Mercenary85
Wed Apr 07, 2010 6:19 pm
Forum: Common Lisp
Topic: Reading In text file.
Replies: 20
Views: 17299

Re: Reading In text file.

How do i go about "not" reading the parenthesis parts?? You don't need to "not" read the parenthesis. If some file contains something like this: (1 2 3 4 5) then you open that file using with-open-file and you call read directly on the file, the value returned is the list (1 2 3...
by Mercenary85
Wed Apr 07, 2010 5:31 pm
Forum: Common Lisp
Topic: Reading In text file.
Replies: 20
Views: 17299

Re: Reading In text file.

How do i go about "not" reading the parenthesis parts??
by Mercenary85
Wed Apr 07, 2010 4:13 pm
Forum: Common Lisp
Topic: Reading In text file.
Replies: 20
Views: 17299

Re: Reading In text file.

(defun read-setup (file) (with-open-file (stream file :direction :input) (loop for input = (read stream nil stream) until (eq input stream) collect input))) (defparameter *imalist* (list)) (setf *imalist* (read-setup "thefile.txt")) would something like this work? it seems to work but I w...
by Mercenary85
Wed Apr 07, 2010 4:06 pm
Forum: Common Lisp
Topic: Reading In text file.
Replies: 20
Views: 17299

Re: Reading In text file.

(defun read-setup (file) (with-open-file (stream file :direction :input) (loop for input = (read stream nil stream) until (eq input stream) collect input))) (defparameter *imalist* (list)) (setf *imalist* (read-setup "thefile.txt")) would something like this work? it seems to work but I w...
by Mercenary85
Wed Apr 07, 2010 3:58 pm
Forum: Common Lisp
Topic: Reading In text file.
Replies: 20
Views: 17299

Re: Reading In text file.

ya see i tried this (defun read-setup (thefile) (with-open-file (stream thefile) (loop for line = (read stream nil 'end) until (eq line 'end) do (print (list (coerce line 'integer) ) ) ) ) ) (defparameter *imalist* (list)) (setf *imalist* (read-setup "thefile.txt")) then tried (print *imal...
by Mercenary85
Wed Apr 07, 2010 2:34 pm
Forum: Common Lisp
Topic: Reading In text file.
Replies: 20
Views: 17299

Re: Reading In text file.

Yes. (setf x y) stores y into the place currently known as x. So my above code should work then? a buddy of mine suggested these (setf example-list (read-file "data.txt")) (loop for data in example-list do (setf ternary-tree (insert data ternary-tree)) ) (defun read-file (file-name) (setf...
by Mercenary85
Wed Apr 07, 2010 1:26 pm
Forum: Common Lisp
Topic: Reading In text file.
Replies: 20
Views: 17299

Re: Reading In text file.

I understand the readin part. but I still dont see how that puts it into the global variable *mylist*? Like if I define *mylist* as a parameter list thats blank. then I read in the numbers from data.txt and data.txt contains (5 6 7 1 5 12 6 7) then after I readin. I want *mylist* (the global variabl...
by Mercenary85
Wed Apr 07, 2010 12:05 pm
Forum: Common Lisp
Topic: Reading In text file.
Replies: 20
Views: 17299

Re: Reading In text file.

Ok basically here is what Im trying to do. I have a global parameter *mylist* that defines a list (like 1 3 5 6 3 1) etc... Right now Im just using that as an example. What I want to do is read in a text file (which consists of JUST integers) into the global parameter *mylist*. thats all I need to d...
by Mercenary85
Wed Apr 07, 2010 10:14 am
Forum: Common Lisp
Topic: Reading In text file.
Replies: 20
Views: 17299

Re: Reading In text file.

To change the value of a variable, use setf . Like this: (defun read-integers-from-file (file) ;; reads file and returns a list with the integers inside it ...) (defparameter *imalist* (list)) (setf *imalist* (read-integers-from-file "/path/to/mydata.txt")) Oh ok that makes sense. in the ...
by Mercenary85
Tue Apr 06, 2010 10:04 pm
Forum: Common Lisp
Topic: Reading In text file.
Replies: 20
Views: 17299

Reading In text file.

Hi All im new to the site. Having a bit of a problem, im pretty new to lisp but I've been trying to learn it just as something to experiment with for fun :) Anyways Im trying to figure out how to read in data and store it as kinda a global parameter. Like for instance (dunno if I can do this) (defpa...