aboutsummaryrefslogtreecommitdiff
path: root/test/boolnum.adb
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2026-01-06 23:28:18 +1300
committerJedidiah Barber <contact@jedbarber.id.au>2026-01-06 23:28:18 +1300
commit009dd1f9cbbd024f8bfd925989e2482f48abe71d (patch)
treecfc56c29b51d9dd44d55ed78272fa5af85f383c2 /test/boolnum.adb
parenta0d71be199c82b78815f64e151a0f208ef87cb05 (diff)
Demonstration program for using arbitrary zero and one elements in Math generic
Diffstat (limited to 'test/boolnum.adb')
-rw-r--r--test/boolnum.adb57
1 files changed, 57 insertions, 0 deletions
diff --git a/test/boolnum.adb b/test/boolnum.adb
new file mode 100644
index 0000000..0539594
--- /dev/null
+++ b/test/boolnum.adb
@@ -0,0 +1,57 @@
+
+
+-- Programmed by Jedidiah Barber
+-- Licensed under the Sunset License v1.0
+
+-- See license.txt for further details
+
+
+with
+
+ Ada.Text_IO,
+ Kompsos.Math,
+ Kompsos.Pretty_Print;
+
+
+procedure Boolnum is
+
+ package TIO renames Ada.Text_IO;
+
+
+ package BKomp is new Kompsos (Boolean);
+ use BKomp;
+
+ package Math is new BKomp.Math (False, True);
+
+ package Printer is new BKomp.Pretty_Print (Boolean'Image);
+
+
+ Relation : Goal := Empty_Goal;
+
+ Four : constant Term := Math.Build (4);
+ Five : constant Term := Math.Build (5);
+ Nine : constant Term := Math.Build (9);
+
+ Sum : constant Term := Relation.Fresh;
+ Product : constant Term := Relation.Fresh;
+
+ Result : State;
+
+begin
+
+ TIO.Put_Line ("Demonstration of arithmetic using boolean zero and one elements.");
+ TIO.New_Line;
+
+ Math.Add (Relation, Five & Nine & Sum);
+ Math.Multiply (Relation, Four & Five & Product);
+
+ Result := Relation.Run;
+
+ TIO.Put_Line (Printer.Image (Five) & " + " & Printer.Image (Nine) &
+ " = " & Printer.Image (Sum.Resolve (Result)));
+ TIO.Put_Line (Printer.Image (Four) & " * " & Printer.Image (Five) &
+ " = " & Printer.Image (Product.Resolve (Result)));
+
+end Boolnum;
+
+