home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / lisp / mcl / 1551 < prev    next >
Encoding:
Text File  |  1992-11-06  |  1.4 KB  |  48 lines

  1. Path: sparky!uunet!charon.amdahl.com!pacbell.com!decwrl!sdd.hp.com!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!data.nas.nasa.gov!taligent!apple!cambridge.apple.com!squeegee@world.std.com
  2. From: squeegee@world.std.com (Stephen C. Gilardi)
  3. Newsgroups: comp.lang.lisp.mcl
  4. Subject: ascii to float--more info
  5. Message-ID: <199211052350.AA17952@world.std.com>
  6. Date: 5 Nov 92 23:50:46 GMT
  7. Sender: info-mcl-request@cambridge.apple.com
  8. Lines: 36
  9. Approved: comp.lang.lisp.mcl@Cambridge.Apple.C0M
  10. Original-To: info-mcl@cambridge.apple.com
  11.  
  12. I received a request fvor more of my code to support my request for a faster
  13. way to parse floats from a text file in MCL.  
  14.  
  15. As I mentioned in my original post, the routine I'm seeking to replace is:
  16.  
  17. (defun parse-float (s)
  18.   (read s))
  19.  
  20. This is slow (among other reasons) because it allocates 150 bytes or so
  21. of memory for each float read.
  22.  
  23. The argument s is a stream.
  24.  
  25. Here is a routine which calls the above routine
  26.  
  27. (defun parse-real-values (npts nvars s)
  28.   (let ((array (make-array (list npts nvars) :element-type 'float)))
  29.     (dotimes (i npts)
  30.       (parse-float s)             ;ignore index in file before first value
  31.       (dotimes (j nvars)
  32.         (setf (aref array i j) (parse-float s))))
  33.     array))
  34.  
  35. This returns an array of real values.
  36.  
  37. Thanks for any help.
  38.  
  39. BTW I thought this list was echoed to comp.lang.lisp.mcl.  Is that the 
  40. case?
  41.  
  42. Thanks,
  43. --Steve
  44.  
  45. Stephen C. Gilardi
  46. SQ Software
  47. squeegee@world.std.com
  48.