vector3-io /

#!/usr/bin/env io
# Make a 3d-vector class
Vector3 := Object clone;
Vector3 make := method(x, y, z,
                       result := Vector3 clone;
                       result x := x;
                       result y := y;
                       result z := z;

# Add dot product function
Vector3  := method(other,
                    other x * x +  
                    other y * y +  
                    other z * z

# Add cross product function
Vector3  := method(other,
                    Vector3 make (
                            y * other z - z * other y,
                            z * other x - x * other z,
                            x * other y - y * other x

# Make the functions infix operators in the language
# (2 is the same precedence level as *, / and %)
OperatorTable addOperator("⋅", 2)
OperatorTable addOperator("⨯", 2)

# Test case needs to be in a different file, since tokenizing
# happened before ⋅ and ⨯ were operators.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.