Skip to content

Instantly share code, notes, and snippets.

@Ventsislav-Yordanov
Created February 20, 2019 14:40
Show Gist options
  • Save Ventsislav-Yordanov/8e7f8bb619e3ecbde799140fc977fbaf to your computer and use it in GitHub Desktop.
Save Ventsislav-Yordanov/8e7f8bb619e3ecbde799140fc977fbaf to your computer and use it in GitHub Desktop.
from typing import List
Vector = List[float]
def scale(scalar: float, vector: Vector) -> Vector:
return [scalar * num for num in vector]
# typechecks; a list of floats qualifies as a Vector.
new_vector = scale(2.0, [1.0, -4.2, 5.4])
print(new_vector)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment