Subject: Re: newbie needs a little help parsing a comma delimited file
From: rpw3@rigden.engr.sgi.com (Rob Warnock)
Date: 1999/10/04
Newsgroups: comp.lang.lisp
Message-ID: <7t9n4q$d736v@fido.engr.sgi.com>
Kent M Pitman  <pitman@world.std.com> wrote:
+---------------
| (defvar *my-readtable* (copy-readtable *readtable*))
| (set-syntax-from-char #\, #\Space *my-readtable*)
| (defun parse-comma-delimited-numbers-from-string (string)
|   (with-input-from-string (string-stream string)
|     (parse-comma-delimited-numbers-from-stream string-stream)))
| (defun parse-comma-delimited-numbers-from-stream (stream)
|   (let ((*readtable* *my-readtable*)
|         (*read-eval* nil)) ;disable trojan horses
|     (loop for x = (read stream nil nil)
|           while x
|           collect x)))
| 
| (parse-comma-delimited-numbers-from-string "1.0,3.0,5.3d7,6.2")
| => (1.0 3.0 5.3E7 6.2)
| 
| ;; Note: I tested an earlier version of this but then edited it a lot
| ;;  to make it prettier so may have broken it somewhere along the way.
| ;;  The basic concept should work, though.
+---------------

Hmmm... The test case works fine in CLISP, but CMUCL 18b complains:

	* (parse-comma-delimited-numbers-from-string "1.0,3.0,5.3d7,6.2")
	Reader error at 4 on #<String-Input Stream>:
	Comma not inside a backquote.
	[...thence to debugger...]


-Rob

-----
Rob Warnock, 8L-846		rpw3@sgi.com
Applied Networking		http://reality.sgi.com/rpw3/
Silicon Graphics, Inc.		Phone: 650-933-1673
1600 Amphitheatre Pkwy.		FAX: 650-933-0511
Mountain View, CA  94043	PP-ASEL-IA