<div dir="ltr">Hello,<div><br></div><div>Can anyone please tell me how to process all the files in a directory.<div><br></div><div>This is what I am doing:</div><div><br></div><div>(check-progs (directory-list "/home/racket/progs"))</div>
<div><br></div><div><div>(define (check-progs flist)</div><div> (if(list? flist)</div><div> (if(null? (cdr flist))</div><div> '()</div><div> (check-progs (cdr flist)))</div><div> (process (simple-form-path (car flist)))))</div>
<div><br></div><div><br></div><div><div>(define (process path)</div><div> (local-require path)</div><div> (local-require rackunit)</div><div> (check-equal? (twice 2) 4)</div><div><br></div><div>Thanks in advance.</div>
<div>Colum</div></div><br><div class="gmail_quote">On Tue, Sep 28, 2010 at 5:13 PM, Deren Dohoda <span dir="ltr"><<a href="mailto:deren.dohoda@gmail.com">deren.dohoda@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Colum, what you're looking for, I believe, is local-require.<br>
<div><div></div><div class="h5"><br>
On Tue, Sep 28, 2010 at 5:07 PM, A Z <<a href="mailto:ukbc57@gmail.com">ukbc57@gmail.com</a>> wrote:<br>
> Hello,<br>
><br>
> There is a problem. 'require' does not go inside the definition of a<br>
> function. DrRacket complains that it needs to go in a module.<br>
><br>
> I need (require path) inside a function because I want to run functions from<br>
> each .rkt file in a directory. I can write (require "file.rkt") for each of<br>
> the file at the top, but that does not look good.<br>
><br>
> Thanks everyone.<br>
> Colum<br>
><br>
><br>
> On Tue, Sep 28, 2010 at 12:32 AM, John Clements <<a href="mailto:clements@brinckerhoff.org">clements@brinckerhoff.org</a>><br>
> wrote:<br>
>><br>
>> On Sep 27, 2010, at 3:35 PM, A Z wrote:<br>
>><br>
>> > Hello Horace,<br>
>> ><br>
>> > I thank you for patiently explaining me how to run racket from command<br>
>> > line.<br>
>> ><br>
>> > Actually, this is not exactly what I am looking for.<br>
>> ><br>
>> > What I want is a script file. Such that I can test the modules of the<br>
>> > program from command prompt.<br>
>> ><br>
>> > Something like<br>
>> ><br>
>> > *******<br>
>> > #!/bin/bash<br>
>> > racket -f "file.rkt"<br>
>> ><br>
>> > racket (twice 2)<br>
>> > *******<br>
>><br>
>> Ah! Caught.<br>
>><br>
>> Okay, you want a file that tests another file. The easy way to do this is<br>
>> not to dip into shell programming at all, but to write your script as<br>
>> another racket program. For the example you provide:<br>
>><br>
>> ****<br>
>> #lang racket<br>
>><br>
>> (require "file.rkt")<br>
>> (require rackunit)<br>
>><br>
>> (check-equal? (twice 2) 4)<br>
>> *****<br>
>><br>
>><br>
>> Then just run this file from the command-line. If it were called<br>
>> 'tests.rkt', you could run it as<br>
>><br>
>> racket tests.rkt<br>
>><br>
>><br>
>><br>
>> John Clements<br>
>><br>
><br>
><br>
</div></div><div><div></div><div class="h5">> _________________________________________________<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>
><br>
</div></div></blockquote></div><br></div></div></div>