Skip to content

Instantly share code, notes, and snippets.

@wdkrnls
Created January 22, 2017 23:02
Show Gist options
  • Save wdkrnls/93f8f462dc03b8618ddf8b2885512f0b to your computer and use it in GitHub Desktop.
Save wdkrnls/93f8f462dc03b8618ddf8b2885512f0b to your computer and use it in GitHub Desktop.
#!/usr/bin/env racket
#lang racket/base
(require racket/vector)
;; Capture the command line args sent to this script
(define args
(current-command-line-arguments))
;; Non-trivial function to apply to vector goes here
(define (f x) (sqrt x))
;; Convert commandline arguments into numeric format
(define xs
(vector-map string->number args))
;; Map the function across the vector
(define ys
(vector-map f xs))
;; Print the results
(for ([y (in-vector ys)]) (displayln y))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment