G.1. Generic Algebraic Bodies - JulTob/Ada GitHub Wiki

The Element type represents algebra. It can be any algebraic set.

The Unit value of the type.

We define the successor function

We also define a Is_Factor function for divisibility. Returns a boolean. Checks if E is divisible by P

Put writes down the variable's value, of the Element type.

The exported procedure Criba tries a sequence of values of the type Element starting at Unit and as given by calls of Succ and checks to see whether they are prime.

Each prime number is output via the child package Eratosthenes.Frame. A total of #To_Try values are tried and the number of primes found is returned in Found.

generic 
   type Element is private;
   Unit: in Element;
   with function Succ(E: Element) return Element;
   with function Is_Factor(E, P: Element) return Boolean;
   with procedure Put(E: in Element);