in reply to about the application of arrow operator
It looks like $a and $b are objects of a class having member functions X, Y and Z. Also, based on the name of the subroutine, it's simply computing the inner product of vectors $a and $b. So imagine that $a->X returns the X component of vector $a, $a->Y the Y component, etc.
So the function is computing (A.x*B.x) + (A.y*B.y) + (A.z*B.z).
$ cat foo.pl use strict; use warnings; sub new_vec { return bless { vec=>[ @_ ] }, 'flarb' }; my $a = new_vec(1, 2, 3); my $b = new_vec(1, 4, 9); my $t = InProduct($a, $b); print "t=$t\n"; sub InProduct { my ($a, $b) = @_; return $a->X*$b->X + $a->Y*$b->Y + $a->Z*$b->Z; } package flarb; sub X { my $self=shift; return $self->{vec}[0] }; sub Y { my $self=shift; return $self->{vec}[1] }; sub Z { my $self=shift; return $self->{vec}[2] }; $ perl foo.pl t=36
...roboticus
When your only tool is a hammer, all problems look like your thumb.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: about the application of arrow operator
by windcrazy86 (Novice) on Aug 29, 2017 at 16:42 UTC |