Re: [racket-users] Help needed in file processing idioms

2016-08-20 Thread WarGrey Gyoudmon Ju
see docs for (read-line) On Sat, Aug 20, 2016 at 5:16 PM, Pekka Niiranen wrote: > Thank you guys, > > > both functions work. Looks like single function (for/or) could be used > if the calling side handles #f, #t and a list. > > Another issue: > > I am planning to

Re: [racket-users] Help needed in file processing idioms

2016-08-20 Thread Pekka Niiranen
Thank you guys, both functions work. Looks like single function (for/or) could be used if the calling side handles #f, #t and a list. Another issue: I am planning to support both Unix and Windows, but have not found a way to define 'return-linefeed as system-wide default (aside using global

Re: [racket-users] Help needed in file processing idioms

2016-08-19 Thread Gustavo Massaccesi
Minor fix: In the first function "read-on-row" you must replace for/first with for/last. Gustavo PS for Pekka: In this case it's better to use for/last and for/or, but in more complicated cases you can try with for/fold. On Fri, Aug 19, 2016 at 10:34 AM, WarGrey Gyoudmon Ju

Re: [racket-users] Help needed in file processing idioms

2016-08-19 Thread WarGrey Gyoudmon Ju
(define (read-on-row *params*) ;; Returns the last line in "myfile" which contains ;; substring "ON", otherwise #f (call-with-input-file (hash-ref *params* "myfile") (lambda (inp) (for/first ([row (in-lines inp 'return-linefeed)] #:when (string-contains? row