Parse command line args as numbers in Racket
racket, scheme
Solution
The result of current-command-line-arguments is a vector. Use `vector-ref` instead of `car`.
(define c (string->number(vector-ref args 0)))
Problem
I am writing a simple script using Racket and I want to pass in three values from the command line. Two floats and an integer. My initial thought was to try this: ``` (define args (current-command-line-arguments)) (define c (string->number(car args))) ``` but that did not work as expected. I received this error: ``` car: contract violation expected: pair? given: '#("3" "2") ``` I'm new to Racket, but I think the the `#` means procedure rather than list. I just need a list of the arguments. I found some documentation on parsing command line args from Racket, but it seems to be designed to parse for switches/options rather than just values. Can anyone offer any advice? thanks.