From: Sam S. <sd...@gn...> - 2002-09-08 21:38:00
|
> * In message <1031482631.4271.6.camel@work> > * On the subject of "[Fwd: Re: [clisp-list] VECTOR-PUSH-EXTEND [was ((SETF STREAM-ELEMENT-TYPE) new-element-type stream)]]" > * Sent on 08 Sep 2002 22:57:11 +1200 > * Honorable Adam Warner <li...@co...> writes: > > Here's the vector-push-extend version: > > (defun unescape-uri (string) > (let ((input-string (substitute #\Newline #\+ string)) > (start-pos 0) > (byte-vector (make-array 1000 :adjustable t :fill-pointer 0 :element-type '(unsigned-byte 8)))) > (loop for pos = (position #\% input-string :start start-pos) until (eq pos nil) > unless (= pos start-pos) do (map nil #'(lambda (x) (vector-push-extend (char-code x) byte-vector)) > (subseq input-string start-pos pos)) > do (vector-push-extend (parse-integer (subseq input-string (1+ pos) (+ pos 3)) :radix 16) byte-vector) > (setf start-pos (+ pos 3))) > (map nil #'(lambda (x) (vector-push-extend (char-code x) byte-vector)) (subseq input-string start-pos)) > (convert-string-from-bytes byte-vector *terminal-encoding*))) replacing (map nil #'(lambda (x) (vector-push-extend (char-code x) byte-vector)) (subseq input-string start-pos pos)) with (loop for i from start-pos to pos do (vector-push-extend (char-code (aref input-string i)) byte-vector)) will save you consing SUBSEQ and LAMBDA. -- Sam Steingold (http://www.podval.org/~sds) running RedHat7.3 GNU/Linux <http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/> <http://www.mideasttruth.com/> <http://www.palestine-central.com/links.html> I may be getting older, but I refuse to grow up! |