<div><div><div class="gmail_quote">On Sat, Jun 4, 2011 at 12:50, Eli Barzilay <span dir="ltr">&lt;<a href="mailto:eli@barzilay.org">eli@barzilay.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im">11 hours ago, Rodolfo Carvalho wrote:<br>
&gt;<br>
</div><div class="im">&gt; Imagine an scenario that instead of 2 (as above) we had 20 columns<br>
&gt; of a table, and we wanted to return a table of the squares of the<br>
&gt; values for all columns, except for columns 12 and 15 (of course we<br>
&gt; could parse them out and ignore then when processing/returning, but<br>
&gt; you get the idea...)<br>
<br>
</div>A classical mistake that people do when they start playing with<br>
regexps is they forget about the rest of the language and try to do<br>
too much with regexps.  If you have a table with more than 2 numbers,<br>
I&#39;d do it like this:<br>
<br>
  (define t &quot;<br>
    23 12 72367 2772 7272 7777 2.342<br>
    15 45 1e2 1e3 1e4<br>
    32 27 3.1415926&quot;)<br>
<br>
  (map (λ(l) (map string-&gt;number (regexp-match* #px&quot;\\d+&quot; l)))<br>
       (regexp-split #rx&quot;\n&quot; t))<br></blockquote><div><br></div><div><br></div><div>This fails to read &quot;2.342&quot;, &quot;1e4&quot; ...</div><div><br></div><div><div><br></div><div>Following your advice and the piece of code above, I wrote it like this:</div>

</div><div><br></div><div><div>;; Split lines, match numbers and filter-out invalid lines</div><div>(define parsed-data</div><div>  (filter</div><div>   (λ (l) (&gt; (length l) 1))</div><div>   (map (λ (l)</div><div>          (map string-&gt;number (regexp-match* #px&quot;\\b[\\d.e+]+\\b&quot; l)))</div>

<div>        (regexp-split #rx&quot;\n&quot; t))))</div><div><br></div><div>;; Sort by Gflops, convert back to string, attach header and display</div><div>(displayln (string-join</div><div>            (cons</div><div>             &quot;N<span class="Apple-tab-span" style="white-space:pre">        </span>NB<span class="Apple-tab-span" style="white-space:pre">        </span>P<span class="Apple-tab-span" style="white-space:pre">        </span>Q<span class="Apple-tab-span" style="white-space:pre">        </span>Time<span class="Apple-tab-span" style="white-space:pre">        </span>Gflops&quot;</div>

<div>             (map (λ (row) (string-join (map number-&gt;string row) &quot;\t&quot;))</div><div>                  (sort parsed-data</div><div>                        &gt;</div><div>                        #:key last</div>

<div>                        #:cache-keys? #t)))</div><div>            &quot;\n&quot;))</div></div><div><br></div><div><br></div><div>[]&#39;s</div><div><br></div><div>Rodolfo</div><div><br></div></div></div></div>