Data update

This commit is contained in:
Ingy döt Net 2024-11-04 20:28:54 -08:00
parent 52a6ef48dd
commit 157b70a810
604 changed files with 14253 additions and 2100 deletions

View file

@ -1,69 +1,69 @@
Module checkit {
class Vector {
\\ by default are double
a,b,c
Property ToString$ {
Value {
link parent a,b,c to a,b,c
value$=format$("({0}, {1}, {2})",a,b,c)
}
}
Operator "==" {
read n
push .a==n.a and .b==n.b and .c==n.c
}
Operator Unary {
.a-! : .b-! : .c-!
}
Operator "+" {
Read v2
For this, v2 {
.a+=..a :.b+=..b:.c+=..c:
}
}
Function Mul(r) {
vv=this
for vv {
.a*=r:.b*=r:.c*=r
}
=vv
}
Function Dot(v2) {
def double sum
for this, v2 {
sum=.a*..a+.b*..b+.c*..c
}
=sum
}
Operator "*" {
Read v2
For This, v2 {
Push .b*..c-.c*..b
Push .c*..a-.a*..c
.c<=.a*..b-.b*..a
Read .b, .a
}
}
class:
module Vector {
if match("NNN") then {
Read .a,.b,.c
}
}
}
A=Vector(3,4,5)
B=Vector(4,3,5)
C=Vector(-5,-12,-13)
Print "A=";A.toString$
Print "B=";B.toString$
Print "C=";C.toString$
Print "A dot B="; A.dot(B)
AxB=A*B
Print "A x B="; AxB.toString$
Print "A dot (B x C)=";A.dot(B*C)
AxBxC=A*(B*C)
Print "A x (B x C)=";AxBxC.toString$
Def ToString$(a)=a.toString$
Print "A x (B x C)=";ToString$(A*(B*C))
Class Vector {
private:
single a,b,c
public:
Property ToString$ {
Value {
link parent a,b,c to a,b,c
value$=format$("({0}, {1}, {2})",a,b,c)
}
}
Operator "==" {
read n as vector
push .a==n.a and .b==n.b and .c==n.c
}
Operator Unary {
.a-! : .b-! : .c-!
}
Operator "+" {
Read v2 as Vector
For this, v2 {
.a+=..a :.b+=..b:.c+=..c:
}
}
Function Mul(r as single) {
vv=this
for vv {
.a*=r:.b*=r:.c*=r
}
=vv
}
Function Dot(v2 as Vector) {
def double sum
for this, v2 {
sum=.a*..a+.b*..b+.c*..c
}
=sum
}
Operator "*" (v2 as Vector) {
For This, v2 {
Push .b*..c-.c*..b
Push .c*..a-.a*..c
.c<=.a*..b-.b*..a
Read .b, .a
}
}
Class:
module Vector {
if match("NNN") then {
Read .a,.b,.c
}
}
}
A=Vector(3,4,5)
B=Vector(4,3,5)
C=Vector(-5,-12,-13)
Print "A=";A.toString$
Print "B=";B.toString$
Print "C=";C.toString$
Print "A dot B="; A.dot(B)
AxB=A*B
Print "A x B="; AxB.toString$
Print "A dot (B x C)=";A.dot(B*C)
AxBxC=A*(B*C)
Print "A x (B x C)=";AxBxC.toString$
Def ToString$(a)=a.toString$
Print "A x (B x C)=";ToString$(A*(B*C))
}
Checkit