-- 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 Divo is package TIO renames Ada.Text_IO; package InKomp is new Kompsos (Integer); use InKomp; package Math is new InKomp.Math (0, 1); package Printer is new InKomp.Pretty_Print (Integer'Image); function B (Item : in Natural) return Term renames Math.Build; function P (Item : in Integer) return String renames Printer.Image; function PV (Item : in Term) return String is begin return P (Math.Value (Item)); exception when others => return Printer.Image (Item); end PV; procedure Test (Dividend, Divisor : in Natural) is Relation : Goal := Empty_Goal; Quotient : constant Term := Relation.Fresh; Remainder : constant Term := Relation.Fresh; Result : State; begin Math.Divide (Relation, B (Dividend) & B (Divisor) & Quotient & Remainder); TIO.Put (P (Dividend) & " / " & P (Divisor) & " = "); Result := Relation.Run; TIO.Put_Line (PV (Quotient.Resolve (Result)) & " r " & PV (Remainder.Resolve (Result))); end Test; begin TIO.Put_Line ("Division"); Test (0, 2); Test (1, 1); Test (2, 3); Test (2, 1); Test (1, 5); Test (3, 2); Test (6, 7); Test (6, 3); Test (4, 6); Test (3, 1); Test (5, 6); Test (19, 7); end Divo;