summaryrefslogtreecommitdiff
path: root/vec.c
diff options
context:
space:
mode:
Diffstat (limited to 'vec.c')
-rw-r--r--vec.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/vec.c b/vec.c
new file mode 100644
index 0000000..74ccc5a
--- /dev/null
+++ b/vec.c
@@ -0,0 +1,26 @@
+#include <u.h>
+#include <libc.h>
+
+typedef struct Vec Vec;
+struct Vec {
+ double x, y, z;
+};
+
+Vec
+addvec(Vec a, Vec b)
+{
+ a.x += b.x;
+ a.y += b.y;
+ a.z += b.z;
+ return a;
+}
+
+void
+main()
+{
+ Vec a = {20, 5, 3};
+ Vec b = {6, -2, 19};
+
+ a = addvec(a, b);
+ exits(nil);
+}