سؤال

I have created a function that is supposed to have lexical variables of type ARRAY:

(defun give-rank-vec (dir-1 dir-2 file-1 file-2)
  (let* ((cm-size (array-dimension (Swc (make-ff-array dir-1 file-1)
                                        (make-ff-array dir-2 file-2)) 
                                    0))
         (rank-dump-vec (make-array `(,cm-size)))     
         (Swc' (Swc (make-ff-array dir-1 file-1)
                    (make-ff-array dir-2 file-2))) 
         (Sbc' (Sbc (make-ff-array dir-1 file-1) 
                    (make-ff-array dir-2 file-2))))
    (dotimes (j cm-size) 
      (setf (svref rank-dump-vec j) 
            (/ (get-element Sbc' j j) 
               (get-element Swc' j j))))   
   rank-dump-vec))  



(defun Sbc (cmatrix1 cmatrix2)
  (add-matrices (Si cmatrix1) 
                (Si cmatrix2)))


(defun add-matrices (A B)
  (let ((C (make-array (array-dimensions A))))
    (dotimes (i (array-dimension A 0))
      (dotimes (j (array-dimension A 1))
        (setf (aref C i j) (+ (aref A i j) (aref B i j)))))
    C))

However when I SLIME this function I get the error:

The value
  (SBC (MAKE-FF-ARRAY DIR-1 FILE-1)
       (MAKE-FF-ARRAY DIR-2 FILE-2))
is not of type
  ARRAY.
   [Condition of type TYPE-ERROR]

Swc works fine, in that seems to return an array- however Sbc doesn't- I tested Sbc with small and huge (wc 13000 65000 627677) flat files and it returned an array when called in SLIME, however it isn't working in this case. The let* expression seems to be written right- I'm not sure what I'm doing wrong here.

هل كانت مفيدة؟

المحلول

The single quote character ' is a terminating macro character in Common Lisp. See the Figure 2-7 in the Hyperspec.

If you want to use this character in a symbol you have to quote it with a backslash or a pair of vertical bars:

CL-USER 65 > '(quote-at-the-end-\' |QUOTE-AT-THE-END-'| quote-at-the-end-|'|)
(QUOTE-AT-THE-END-\' QUOTE-AT-THE-END-\' QUOTE-AT-THE-END-\')
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top