Vector products: Difference between revisions
→{{header|REXX}}: Improve readability and make it ooRexx conform
m (→{{header|Wren}}: Changed to Wren S/H) |
Walterpachl (talk | contribs) (→{{header|REXX}}: Improve readability and make it ooRexx conform) |
||
(4 intermediate revisions by one other user not shown) | |||
Line 1,448:
=={{header|Delphi}}==
See [https://rosettacode.org/wiki/Vector_products#Pascal Pascal].
=={{header|EasyLang}}==
<syntaxhighlight>
func vdot a[] b[] .
for i to len a[]
r += a[i] * b[i]
.
return r
.
func[] vcross a[] b[] .
r[] &= a[2] * b[3] - a[3] * b[2]
r[] &= a[3] * b[1] - a[1] * b[3]
r[] &= a[1] * b[2] - a[2] * b[1]
return r[]
.
a[] = [ 3 4 5 ]
b[] = [ 4 3 5 ]
c[] = [ -5 -12 -13 ]
#
print vdot a[] b[]
print vcross a[] b[]
print vdot a[] vcross b[] c[]
print vcross a[] vcross b[] c[]
</syntaxhighlight>
{{out}}
49
[ 5 5 -7 ]
6
[ -267 204 -3 ]
</pre>
=={{header|EchoLisp}}==
Line 4,598 ⟶ 4,630:
=={{header|REXX}}==
<syntaxhighlight lang="rexx">/*REXX program computes the products:
b= 4 3 5
Say ''
/*---------------------------------------------------------------------------*/
cross: Procedure
Arg a b c, u v w
Return b*w-c*v c*u-a*w a*v-b*u
dot: Procedure
tellV: procedure; parse arg name,x y z; w=max(4,length(x),length(y),length(z)) /*max W*/▼
Arg a b c, u v w
say right(name,40) right(x,w) right(y,w) right(z,w); /*show vector.*/ return</syntaxhighlight>▼
Return a*u + b*v + c*w
{{out|output|text= when using the default internal inputs:}}▼
/*---------------------------------------------------------------------------*/
tellV: Procedure
Parse Arg name,x y z
▲
Return</syntaxhighlight>
<pre>
▲</pre>
=={{header|Ring}}==
|