Ejemplo n.º 1
0
w = Vec({'A', 'B', 'C'}, {'A': 2, 'B': 4})
for d in v.D:
    if d in v.f:
        print(v.f[d])

print(Vec.__getitem__(v, 'A'))

Vec.__setitem__(v, 'B', 2)

print(Vec.__getitem__(v, 'B'))

print("V\n")
print(v)
print("W\n")
print(w)
print("\n\nDotProduct of v and w\n")
print(Vec.__mul__(v, w))

print("Add v and w to create x\n")
x = Vec.__add__(v, w)

print(x)
print("Scale x by 2\n")
x = Vec.__rmul__(x, 2)
print(x)
print("Add x and w\n")
print(Vec.__add__(x, w))

print("Negate x\n")
print(Vec.__neg__(x))