export default function createVector({x, y}) {
	return {
		get x() {
			return x;
		},
		set x(v) {
			x = v;
		},
		get y() {
			return y;
		},
		set y(v) {
			y = v;
		},
		get norm() {
			return Math.sqrt(this.x*this.x + this.y*this.y);
		},
		add({x, y}) {
			return createVector({x: this.x + x, y: this.y + y});
		},
		sub({x, y}) {
			return createVector({x: this.x - x, y: this.y - y});
		},
		mul(k) {
			return createVector({x: this.x*k, y: this.y*k});
		},
		distance({x, y}) {
			return this.sub(createVector({x, y})).norm();
		},
		equal({x, y}) {
			return this.x === x && this.y === y;
		},
		isNull() {
			return this.x === 0 && this.y === 0;
		}
	};
}

@@ -86,85 +86,29 @@
 ,%0A%09%09
-set x(v) %7B%0A%09%09%09x = v;%0A%09%09%7D,%0A%09%09get y() %7B%0A%09%09%09return y;%0A%09%09%7D,%0A%09%09set y(v) %7B%0A%09%09%09y = v
+get y() %7B%0A%09%09%09return y
 ;%0A%09%09
@@ -336,16 +336,71 @@
 );%0A%09%09%7D,%0A
+%09%09scalar(%7Bx, y%7D) %7B%0A%09%09%09return this.x*x + this.y*y;%0A%09%09%7D,%0A
 %09%09mul(k)

add scalar method