Skip to content

Latest commit

 

History

History

hac-examples

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

HAC Examples

HAC Project Directory hac-examples\ contains Ada code examples coming from the HAC project.

We support the following build tools :

Build tool Build file
gnatmake.exe 1
gprbuild.exe build.gpr

Ackermann Example

This code example consists of source file ackermann.adb.

> build -verbose run
Compile 5 Ada source files into directory "target\obj"
Execute Ada program "target\Ackermann.exe"
Ackermann function
     1     2     3     4     5     6     7
     2     3     4     5     6     7     8
     3     5     7     9    11    13    15
     5    13    29    61   125   253   509
> make -s run
Ackermann function
     1     2     3     4     5     6     7
     2     3     4     5     6     7     8
     3     5     7     9    11    13    15
     5    13    29    61   125   253   509
> gprbuild & target\Ackermann.exe
using project file build.gpr
Setup
   [mkdir]        object directory for project Build
Compile
   [Ada]          ackermann.adb
   [Ada]          hat.adb
Bind
   [gprbind]      ackermann.bexch
   [Ada]          ackermann.ali
Link
   [link]         ackermann.adb
Ackermann function
     1     2     3     4     5     6     7
     2     3     4     5     6     7     8
     3     5     7     9    11    13    15
     5    13    29    61   125   253   509

Binomials Example

Example Binomialshas the following directory structure :

> tree /a /f . | findstr /v /b [A-Z]
|   build.bat
|   build.gpr
|   build.sh
|   Makefile
\---src
    \---main
        \---ada
                binomials.adb

Command build -verbose run generates and executes the program target\Binomials.exe :

> build -verbose run
Compile 5 Ada source files into directory "target\obj"
Execute Ada program "target\Binomials.exe"
n = 1
k= binomial (n,k)=
 
n = 2
k= binomial (n,k)=
1: 2
 
n = 3
k= binomial (n,k)=
1: 3
2: 3
 
n = 4
k= binomial (n,k)=
1: 4
2: 6
3: 4
 
[...]

Footnotes

[1] Gnatmake

GNU tools such as gcc, gnatmake, objdump and windres are available both in the MSYS installation and in the GNAT 2021 installation; we use the tools from the MSYS installation which have newer versions.
> where gcc gnatmake windres
C:\opt\msys64\usr\bin\gcc.exe
C:\opt\msys64\mingw64\bin\gcc.exe
C:\opt\GNAT\2021\bin\gcc.exe
C:\opt\msys64\mingw64\bin\gnatmake.exe
C:\opt\GNAT\2021\bin\gnatmake.exe
C:\opt\msys64\usr\bin\windres.exe
C:\opt\msys64\mingw64\bin\windres.exe
C:\opt\GNAT\2021\bin\windres.exe
 
> C:\opt\msys64\mingw64\bin\gnatmake.exe --version
GNATMAKE 13.2.0
Copyright (C) 1995-2023, Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
> C:\opt\GNAT\2021\bin\gnatmake.exe --version
GNATMAKE Community 2021 (20210519-103)
Copyright (C) 1995-2021, Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

mics/February 2025