Higher order functions will be what you are looking for. In this case - map and vector-map. <div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><a href="http://docs.racket-lang.org/reference/pairs.html#(def._((lib._racket/private/map..rkt)._map))" target="_blank">http://docs.racket-lang.org/reference/pairs.html#(def._((lib._racket/private/map..rkt)._map))</a></div>
<div><br></div><div><a href="http://docs.racket-lang.org/reference/vectors.html#(def._((lib._racket/vector..rkt)._vector-map))" target="_blank">http://docs.racket-lang.org/reference/vectors.html#(def._((lib._racket/vector..rkt)._vector-map))</a></div>
</blockquote><div><br></div><div>Use map to iterate over the list of vectors, then use vector-map to iterate over the cells within the vectors to apply the regexp-replace* function. </div><div><br></div><div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace; "> (map (lambda (vector) </span></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> (vector-map (lambda (cell) <apply_proc_to_individual_cell ...>) vector)) </font></div><div><font class="Apple-style-span" face="'courier new', monospace"> <your_list_of_vectors>) </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div></div><div>HTH. Cheers,</div>
<div>yc<br><br><div class="gmail_quote">On Mon, Oct 18, 2010 at 2:23 PM, scouic <span dir="ltr"><<a href="mailto:scouic@gmail.com" target="_blank">scouic@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi all,<br>here more than three hours that i'm locked on a function, i defer to you =)<br>My problem : i have a list of vectors, each vectors represents a text syntax (not html syntax, just text), and were created with the result of a format sqlite SELECT operation.<br>
<br>For example, my list of vectors L is like this :<br>(define L '(#("nickname || ' ( ' || date || ' )' || content") <br> #("zobi ( Thursday, October 14th, 2010 12:40:51pm ) <p>try</p>") <br>
#("zf ( Thursday, October 14th, 2010 12:43:56pm ) (a ((href \"foo.html\")) \"sometext\")")<br> #("zf2 ( Thursday, October 14th, 2010 12:44:59pm ) (a ((href \"bar.html\")) \"anotherone\")")))<br>
<br>So, (first L) is a vector, (second L) too, etc.<br>Now, i want to replace each string, for example "Thursday", by "<<Thursday>>", in my list of vectors.<br><br>I have created a function, wich i call like this :<br>
(rush! L '() "Thursday")<br><br>this is the function :<br>(define (rush! T super-list a-string)<br> (if (empty? T)<br> super-list ;; here is the problem<br> (rush! (rest T)<br> (append<br>
super-list<br> (list (regexp-replace* a-string (vector-ref (first T) 0) (string-append "<<" a-string ">>"))))<br> a-string)))<br><br>Now, if i compare L and (rush! L '() "Thursday"), i have for L:<br>
'(#("nickname || ' ( ' || date || ' )' || content")<br> #("zobi ( Thursday, October 14th, 2010 12:40:51pm ) <p>try</p>")<br> #("zf ( Thursday, October 14th, 2010 12:43:56pm ) (a ((href \"foo.html\")) \"sometext\")")<br>
#("zf2 ( Thursday, October 14th, 2010 12:44:59pm ) (a ((href \"bar.html\")) \"anotherone\")"))<br><br>and for the function :<br>'("zobi ( <<Thursday>>, October 14th, 2010 12:40:51pm ) <p>try</p>"<br>
"zf ( <<Thursday>>, October 14th, 2010 12:43:56pm ) (a ((href \"foo.html\")) \"sometext\")"<br> "zf2 ( <<Thursday>>, October 14th, 2010 12:44:59pm ) (a ((href \"bar.html\")) \"anotherone\")")<br>
<br>BUT it's not a list of vectors, it's a simple list ...<br>Instead of <br> (if (empty? T) super-list ...<br>i've tried (if (empty? T) (list->vector super-list) ... mamamia, it's no a list of vectors, but just a simple vector ...<br>
<br>I really don't know how i can replace a-string into a list of vectors so, because my rush! function doesn't works like i want ...<br><br>Thank you for your help,<br>-mw<br>
<br>_________________________________________________<br>
For list-related administrative tasks:<br>
<a href="http://lists.racket-lang.org/listinfo/users" target="_blank">http://lists.racket-lang.org/listinfo/users</a><br></blockquote></div><br><br clear="all"><br>-- <br>Cheers,<br>yc<br><br>Taming the software dragon - <a href="http://dragonmaestro.com" target="_blank">http://dragonmaestro.com</a><br>
<br>
</div>