-- Programmed by Jedidiah Barber -- Licensed under the Sunset License v1.0 -- See license.txt for further details with Ada.Text_IO, Kompsos.Pretty_Print; procedure FiveSix is package TIO renames Ada.Text_IO; package InKomp is new Kompsos (Integer); use InKomp; package InPrin is new InKomp.Pretty_Print (Integer'Image); use InPrin; -- It is possible to create a recursion using functions like this... function Fives (This : in World) return World is One, Two : World := This; begin One.Unify (One.Fresh, 5); Two.Conjunct (Fives'Access); return Disjunct (One, Two); end Fives; Sixes : World := Empty_World; Result : World; begin TIO.Put_Line ("Test program for fives-and-sixes example from 2013 microKanren paper."); TIO.Put_Line ("Since the result is infinite, only the first five states will be shown."); TIO.New_Line; -- ...but it is a lot simpler and easier to create recursions this way instead. Sixes.Unify (Sixes.Fresh, 6); Sixes.Recurse; Result := Disjunct (Fives (Empty_World), Sixes); -- Note how the States from Fives keep creating new Variables instead of looping. TIO.Put_Line (Image (Result.Take (5))); end FiveSix;