Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command line processing in Racket contains embedded void

What about command-line processing in racket do I not understand? For example, I just want to process the first argument as foo.html. From the command-line I run it as:

racket cmd.rkt foo.html

Unfortunately that just returns:

foo.html'#(#<void>)

Here's the code for cmd.rkt:

(for/vector ([i (current-command-line-arguments)])
    (display i))
like image 586
Panda Avatar asked Mar 11 '26 06:03

Panda


1 Answers

for/vector isn't called that because it iterates over vectors, it's called that because it accumulates the results of its body expression into a vector. So for each commandline argument it evaluates the display call, which prints the argument and returns #<void>, and accumulates the result into a vector of void values.

Use for instead and the problem will go away.

like image 196
jacobm Avatar answered Mar 15 '26 08:03

jacobm