Skip to content

Instantly share code, notes, and snippets.

@danking
Last active December 27, 2015 12:49
Show Gist options
  • Select an option

  • Save danking/7328996 to your computer and use it in GitHub Desktop.

Select an option

Save danking/7328996 to your computer and use it in GitHub Desktop.
(: scale-vector ((Vectorof Natural) -> (Vector of Natural)))
(define (scale-vector vec k)
  (for/vector: : [Vectorof Natural] ([element vec])
     (* k vec)))

But does it really matter that I'm using Naturals? I could replace Natural with any other numeric type that is closed under multiplication (Integer, Rational, Real, Complex) and this should still type check.

(In an earlier revision I said addition)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment