[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
ascii to float--more info
- To: info-mcl@cambridge.apple.com
- Subject: ascii to float--more info
- From: squeegee@world.std.com (Stephen C. Gilardi)
- Date: Thu, 5 Nov 1992 18:50:46 -0500
I received a request fvor more of my code to support my request for a faster
way to parse floats from a text file in MCL.
As I mentioned in my original post, the routine I'm seeking to replace is:
(defun parse-float (s)
(read s))
This is slow (among other reasons) because it allocates 150 bytes or so
of memory for each float read.
The argument s is a stream.
Here is a routine which calls the above routine
(defun parse-real-values (npts nvars s)
(let ((array (make-array (list npts nvars) :element-type 'float)))
(dotimes (i npts)
(parse-float s) ;ignore index in file before first value
(dotimes (j nvars)
(setf (aref array i j) (parse-float s))))
array))
This returns an array of real values.
Thanks for any help.
BTW I thought this list was echoed to comp.lang.lisp.mcl. Is that the
case?
Thanks,
--Steve
Stephen C. Gilardi
SQ Software
squeegee@world.std.com