Sunday 15 August 2010

lisp - code throws me an error: Space is an illegal character after a colon. -



lisp - code throws me an error: Space is an illegal character after a colon. -

sort code, translation made one:

insertion(a) 2 n j=i-1 while (j>=1) , (a[j]>a[j+1])do t=a[j+1] a[j+1]=a[j] a[j]=t j=j-1

and translation lisp

(defun insertion (unsorted-vector) (let ((vector (copy-seq unsorted-vector)) (n (length unsorted-vector))) (loop :for : 2: below (n) :do ((j (- 1)) (loop :do (and (>= (j 1)) (> (aref vector j) (aref vector (+ j 1)))) (rotatef (aref vector j) (aref vector (+ j 1))) (j (- j 1)))) vector))) (insertion #(5 1 3 2))

but throwing me message says: error while reading: #\space illegal character after colon. , don´t understand mean, , don´t know if there other mistakes in code.

because there space. @ code, should write :from or from, not : from, , same thing below.

(defun insertion (unsorted-vector) (let ((vector (copy-seq unsorted-vector)) (n (length unsorted-vector))) (loop :for : 2: below (n) ;; problem ;;; ^^^ ^^^ ;; <= here ;;; alter :from , :below :do ((j (- 1)) (loop :do (and (>= (j 1)) (> (aref vector j) (aref vector (+ j 1)))) (rotatef (aref vector j) (aref vector (+ j 1))) (j (- j 1)))) vector)))

lisp

No comments:

Post a Comment