> Then, for all rows, read and split the string. The best that i have found to 
> do that is using regular expressions.
> 
>   (define split-row (regexp-match #rx"\\[(.+), (.+), (.+)\\]" (read-line)))
> 
> Then you have to manually convert the substrings into values
> 
>   (define a (string->number (second split-row)))
>   (define b (third split-row))
>   (define c (string->number (fourth split-row)))

This kind of destructuring & conversion from strings to values can sometimes be 
more conveniently handled by converting your source data into something that 
looks like Racket S-expressions (in this case, by removing the commas) and then 
calling `read` to do the rest, e.g.

#lang racket
(with-input-from-file "data.txt"
  (λ _ (for/list ([ln (in-lines)])
                 (read (open-input-string (string-replace ln "," ""))))))

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to