Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use "is also" to rearrange definitions in a more natural order.

  • Loading branch information...
commit bdccdbbe176fdea9451c96fbcbb6087693e937af 1 parent 85c3ca2
@LastOfTheCarelessMen authored
Showing with 15 additions and 12 deletions.
  1. +15 −12 lib/Vector.pm
View
27 lib/Vector.pm
@@ -28,10 +28,23 @@ class Vector
{
@.coordinates.elems;
}
-
+}
+
+multi sub infix:<⋅>(Vector $a, Vector $b where { $a.Dim == $b.Dim }) # is tighter(&infix:<+>) (NYI)
+{
+ [+]($a.coordinates »*« $b.coordinates);
+}
+
+multi sub infix:<dot>(Vector $a, Vector $b)
+{
+ $a$b;
+}
+
+class Vector is also
+{
method Length()
{
- sqrt [+] (@.coordinates »*« @.coordinates);
+ sqrt(selfself);
}
method Unitize()
@@ -83,16 +96,6 @@ multi sub infix:<V/>(Vector $a, $b)
Vector.new($a.coordinates >>/>> $b);
}
-multi sub infix:<⋅>(Vector $a, Vector $b where { $a.Dim == $b.Dim }) # is tighter(&infix:<+>) (NYI)
-{
- [+]($a.coordinates »*« $b.coordinates);
-}
-
-multi sub infix:<dot>(Vector $a, Vector $b)
-{
- $a$b;
-}
-
multi sub infix:<×>(Vector $a where { $a.Dim == 3 }, Vector $b where { $b.Dim == 3 })
{
Vector.new($a.coordinates[1] * $b.coordinates[2] - $a.coordinates[2] * $b.coordinates[1],

0 comments on commit bdccdbb

Please sign in to comment.
Something went wrong with that request. Please try again.