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.
The result of current-command-line-arguments is a vector. Use vector-ref instead of car.
(define c (string->number(vector-ref args 0)))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With