RosettaCodeData/Task/Dot-product/PostScript/dot-product.ps
Ingy döt Net d066446780 langs a-z
2013-04-10 22:43:41 -07:00

17 lines
223 B
PostScript

/dotproduct{
/x exch def
/y exch def
/sum 0 def
/i 0 def
x length y length eq %Check if both arrays have the same length
{
x length{
/sum x i get y i get mul sum add def
/i i 1 add def
}repeat
sum ==
}
{
-1 ==
}ifelse
}def