Vector products: Difference between revisions
Content deleted Content added
add Scala |
m →{{header|REXX}}: ordered subroutines in alphabetical order, removed blank lines, added whitespace, changed comments. -- ~~~~ |
||
Line 1,869: | Line 1,869: | ||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
⚫ | |||
<lang rexx> |
|||
⚫ | |||
/* the cross product, */ |
/* the cross product, */ |
||
/* the scalar triple product, and*/ |
/* the scalar triple product, and*/ |
||
/* the vector triple product. */ |
/* the vector triple product. */ |
||
a= 3 4 5 |
a = 3 4 5 /*positive numbers don't need " */ |
||
b= 4 3 5 |
b = 4 3 5 |
||
c="-5 -12 -13" |
c = "-5 -12 -13" |
||
call tellV 'vector A =',a /*show the A vector, aligned #s*/ |
call tellV 'vector A =',a /*show the A vector, aligned #s*/ |
||
Line 1,887: | Line 1,886: | ||
call tellV 'scalar triple product [A∙(BxC)] =',dot(a,cross(b,c)) |
call tellV 'scalar triple product [A∙(BxC)] =',dot(a,cross(b,c)) |
||
call tellV 'vector triple product [Ax(BxC)] =',cross(a,cross(b,c)) |
call tellV 'vector triple product [Ax(BxC)] =',cross(a,cross(b,c)) |
||
exit /*stick a fork in it, we're done.*/ |
|||
exit |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
/*─────────────────────────────────────tellV subroutine─────────────────*/ |
/*─────────────────────────────────────tellV subroutine─────────────────*/ |
||
tellV: procedure; parse arg name,x y z /*display the vector*/ |
tellV: procedure; parse arg name,x y z /*display the vector*/ |
||
w=max(4,length(x),length(y),length(z)) /*max width of nums.*/ |
w=max(4,length(x),length(y),length(z)) /*max width of nums.*/ |
||
say right(name,40) right(x,w) right(y,w) right(z,w) |
say right(name,40) right(x,w) right(y,w) right(z,w) |
||
return |
return</lang> |
||
'''out0ut''' |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
</lang> |
|||
Output: |
|||
<pre style="height:25ex;overflow:scroll"> |
<pre style="height:25ex;overflow:scroll"> |
||
vector A = 3 4 5 |
vector A = 3 4 5 |