[racket] A list of vectors

From: Everett Morse (webj2 at unoc.net)
Date: Mon Oct 18 18:55:09 EDT 2010

On 10/18/2010 03:23 PM, scouic wrote:
> this is the function :
> (define (rush! T super-list a-string)
>   (if (empty? T)
>       super-list ;; here is the problem
>       (rush! (rest T)
>                  (append
>                   super-list
>                   (list (regexp-replace* a-string (vector-ref (first 
> T) 0) (string-append "<<" a-string ">>"))))
>                  a-string)))

> BUT it's not a list of vectors, it's a simple list ...
> Instead of
> (if (empty? T)  super-list ...
> i've tried (if (empty? T) (list->vector super-list) ... mamamia, it's 
> no a list of vectors, but just a simple vector ...

The problem is you use vector-ref to pull the string out of the vector, 
then don't put the result of regexp-replace* back into a vector.  This 
line would do it:

(list #(,(regexp-replace* a-string (vector-ref (first T) 0) 
(string-append "<<" a-string ">>")))))

This is just for general education. YC's method of using map and vector 
map is better for actually doing this.


Posted on the users mailing list.