Lisp 从字符串读取数组中的数字

Lisp 从字符串读取数组中的数字,lisp,common-lisp,Lisp,Common Lisp,我创建静态数组,建议在字符串中查找数组大小的数字 我想一直走到最后 (let((*read eval*nil))(从字符串读取(格式为nil“#(~a)”数据))(let(*read eval*nil))(从字符串读取(格式为nil“#(~a)”数据)) (setf arr (make-array'(5))) (loop for i from 0 to 4 do (if (/= nil (read-from-string str)) (setq x (read-fro

我创建静态数组,建议在字符串中查找数组大小的数字

我想一直走到最后

(let((*read eval*nil))(从字符串读取(格式为nil“#(~a)”数据))
(let(*read eval*nil))(从字符串读取(格式为nil“#(~a)”数据))
(setf arr (make-array'(5))) 

(loop for i from 0 to 4
  do (if (/= nil (read-from-string str)) 
         (setq x (read-from-string str t nil :start i))
         (setf (aref arr i) x))))
(defun string->vector (s)
  (let ((*read-eval* nil))              ;be a bit safe
    (with-input-from-string (in s)
      (loop for e = (read in nil in)
            for n upfrom 0
            until (eq e in)
            collect e into es
            finally (return (make-array n :initial-contents es))))))