init
This commit is contained in:
commit
e1edc387da
|
@ -0,0 +1,4 @@
|
|||
/obj/
|
||||
/bin/
|
||||
/alire/
|
||||
/config/
|
|
@ -0,0 +1,12 @@
|
|||
name = "spark_mode"
|
||||
description = ""
|
||||
version = "0.1.0-dev"
|
||||
|
||||
authors = ["Nicki"]
|
||||
maintainers = ["Nicki <yannick.reiss@nickr.eu>"]
|
||||
maintainers-logins = ["yannickreiss"]
|
||||
licenses = "MIT OR Apache-2.0 WITH LLVM-exception"
|
||||
website = ""
|
||||
tags = []
|
||||
|
||||
executables = ["spark_mode"]
|
|
@ -0,0 +1,23 @@
|
|||
with "config/spark_mode_config.gpr";
|
||||
project Spark_Mode is
|
||||
|
||||
for Source_Dirs use ("src/", "config/");
|
||||
for Object_Dir use "obj/" & Spark_Mode_Config.Build_Profile;
|
||||
for Create_Missing_Dirs use "True";
|
||||
for Exec_Dir use "bin";
|
||||
for Main use ("spark_mode.adb");
|
||||
|
||||
package Compiler is
|
||||
for Default_Switches ("Ada") use Spark_Mode_Config.Ada_Compiler_Switches;
|
||||
for Local_Configuration_Pragmas use "spark.adc";
|
||||
end Compiler;
|
||||
|
||||
package Binder is
|
||||
for Switches ("Ada") use ("-Es"); -- Symbolic traceback
|
||||
end Binder;
|
||||
|
||||
package Install is
|
||||
for Artifacts (".") use ("share");
|
||||
end Install;
|
||||
|
||||
end Spark_Mode;
|
|
@ -0,0 +1,44 @@
|
|||
package body Logic is
|
||||
|
||||
-- @name Step
|
||||
-- @return
|
||||
-- @parameter N:Natural
|
||||
-- @parameter O:Natural
|
||||
-- @description Do one calculation step and safe the result to O.
|
||||
procedure Step (N : Natural; O : out Natural) is
|
||||
|
||||
begin
|
||||
|
||||
if N mod 2 = 0 then
|
||||
O := N / 2;
|
||||
else
|
||||
O := 3 * N + 1;
|
||||
end if;
|
||||
|
||||
end Step;
|
||||
|
||||
-- @name Row
|
||||
-- @return
|
||||
-- @parameter N:Natural,Final
|
||||
-- @description Calculate full row for design.
|
||||
procedure Row (N : Natural; Final : out Natural) is
|
||||
Old : Natural := N;
|
||||
Update : Natural;
|
||||
begin
|
||||
|
||||
while (Old < (Natural'Last / 3)) and (not (Old = 1)) loop
|
||||
|
||||
Step (Old, Update);
|
||||
Old := Update;
|
||||
|
||||
end loop;
|
||||
|
||||
if not (Old = 1) then
|
||||
Old := 1;
|
||||
end if;
|
||||
|
||||
Final := Old;
|
||||
|
||||
end Row;
|
||||
|
||||
end Logic;
|
|
@ -0,0 +1,19 @@
|
|||
package Logic is
|
||||
|
||||
-- @name Step
|
||||
-- @return
|
||||
-- @parameter N:Natural
|
||||
-- @parameter O:Natural
|
||||
-- @description Do one calculation step and safe the result to O.
|
||||
procedure Step (N : Natural; O : out Natural) with
|
||||
Depends => (O => N), Pre => (N < (Natural'Last / 3));
|
||||
|
||||
-- @name Row
|
||||
-- @return
|
||||
-- @parameter N:Natural,Final
|
||||
-- @description Calculate full row for design.
|
||||
procedure Row (N : Natural; Final : out Natural) with
|
||||
Depends => (Final => N), Pre => (N < (Natural'Last / 3)),
|
||||
Post => (Final = 1);
|
||||
|
||||
end Logic;
|
|
@ -0,0 +1,15 @@
|
|||
with Logic; use Logic;
|
||||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
|
||||
procedure Spark_Mode is
|
||||
|
||||
A, B : Natural;
|
||||
|
||||
begin
|
||||
|
||||
A := 8_400;
|
||||
Row (A, B);
|
||||
|
||||
Put_Line (B'Image);
|
||||
|
||||
end Spark_Mode;
|
Loading…
Reference in New Issue