Data update

This commit is contained in:
Ingy döt Net 2025-08-11 18:05:26 -07:00
parent 4d5544505c
commit 4924dd0264
3073 changed files with 55820 additions and 4408 deletions

View file

@ -0,0 +1,31 @@
with Ada.Text_IO;
procedure Vector_Demo is
type Vector is record
X, Y : Float;
end record;
function "+" (A, B : Vector) return Vector is
(A.X + B.X, A.Y + B.Y);
function "-" (A, B : Vector) return Vector is
(A.X - B.X, A.Y - B.Y);
function "*" (S : Float; A : Vector) return Vector is
(S * A.X, S * A.Y);
function "/" (A : Vector; S : Float) return Vector is
(A.X / S, A.Y / S);
procedure Print (A : Vector) is
begin
Ada.Text_IO.Put_Line ("(" & A.X'Image & "," & A.Y'Image & ")");
end Print;
Example : Vector := (1.0, 1.0);
begin
Print (Example + Example);
Print (Example - Example);
Print (2.0 * Example);
Print (Example / 2.0);
end Vector_Demo;

View file

@ -0,0 +1,31 @@
local fmt = require "fmt"
class vector2
static function polar(r, theta)
return new vector2(r * math.cos(theta), r * math.sin(theta))
end
static function scale(s, v) return v * s end
function __construct(public x, public y) end
function __add(v) return new vector2(self.x + v.x, self.y + v.y) end
function __sub(v) return new vector2(self.x - v.x, self.y - v.y) end
function __mul(s) return new vector2(self.x * s, self.y * s) end
function __div(s) return new vector2(self.x / s, self.y / s) end
function __tostring() return $"({self.x}, {self.y})" end
end
local v1 = new vector2(5, 7)
local v2 = new vector2(2, 3)
local v3 = vector2.polar(math.sqrt(2.0), math.pi / 4)
fmt.print("v1 = %s", v1)
fmt.print("v2 = %s", v2)
fmt.print("v3 = %s", v3)
print()
fmt.print("v1 + v2 = %s", v1 + v2)
fmt.print("v1 - v2 = %s", v1 - v2)
fmt.print("v1 * 11 = %s", v1 * 11)
fmt.print("11 * v2 = %s", vector2.scale(11, v2))
fmt.print("v1 / 2 = %s", v1 / 2)

View file

@ -1,4 +1,4 @@
-- 19 May 2025
-- 28 Jul 2025
include Settings
say 'VECTOR'
@ -6,26 +6,23 @@ say version
say
a = '1 2 3'; b = '3 2 1'; c = 3; d = '4 5'; e = '2 1'
say 'VALUES'
say 'A =' Vlst2Form(a)
say 'B =' Vlst2Form(b)
say 'A =' Lst2FormV(a)
say 'B =' Lst2FormV(b)
say 'C =' c
say 'D =' Vlst2Form(d)
say 'E =' Vlst2Form(e)
say 'D =' Lst2FormV(d)
say 'E =' Lst2FormV(e)
say
say 'BASICS'
say 'A+B =' Vlst2Form(Vadd(a,b))
say 'A-B =' Vlst2Form(Vsub(a,b))
say 'A*C =' Vlst2Form(Vmul(a,c))
say 'A/C =' Vlst2Form(Vdiv(a,c))
say 'A+B =' Lst2FormV(AddV(a,b))
say 'A-B =' Lst2FormV(SubV(a,b))
say 'A*C =' Lst2FormV(ScaleV(a,c))
say 'A/C =' Lst2FormV(ScaleV(a,1/c))
say
say 'BONUS'
say 'Length(D) =' Vlen(d)+0
say 'Angle(D) =' Vang(d)+0
say 'Polar(D) =' Vlst2Form(Vrec2Pol(d))
say 'Rect(E) =' Vlst2Form(Vpol2Rec(e))
say 'Length(D) =' LenV(d)+0
say 'Angle(D) =' AngV(d)+0
say 'Polar(D) =' Lst2FormV(Rec2PolV(d))
say 'Rect(E) =' Lst2FormV(Pol2RecV(e))
exit
include Vector
include Functions
include Constants
include Abend
include Math