comp.lang.ada
 help / color / mirror / Atom feed
From: montgrimpulo <aghte@hotlinemail.com>
Subject: Re: Function definitions
Date: Fri, 20 Jun 2014 10:39:37 -0700 (PDT)
Date: 2014-06-20T10:39:37-07:00	[thread overview]
Message-ID: <7597c304-0dc2-41ad-b04e-1aef133e5b63@googlegroups.com> (raw)
In-Reply-To: <610b9d5b-a9a5-464d-9de3-b2f754f58cff@googlegroups.com>

Here is some code:

File search.ads:

package search is

type x_array is array (positive range <>) of Float;
type y_array is array (positive range <>) of Integer;
type z_array is array (positive range <>) of Boolean;

P,Q,R : Natural;

type Individual is record
X : x_array (0..P);
Y : y_array (0..Q);
Z : z_array (0..R);
end record;

function F (V : Individual) return Float;
function G (M : Positive; V : Individual) return Float;

procedure g_search ( P,Q,R : Natural);

...

procedure p1;
procedure p2;

...
end search;

File search.adb

package body search is

V : Individual;

procedure p1 is
FV : Float;
...
begin
...
FV := F(V);
...
end p1;

procedure p2 is
GMV : Float;
M : Positive;
...
begin
...
GMV := G(M,V);
end p2;

procedure g_search (P,Q,R : Natural) is
...
begin
p1;
p2;
...
end g_search;

end search;

File main_search.adb

with search; use search;

procedure main_search is

P := 1;
Q := 1;
R := 1;
 
V : Individual;

function F (V : Individual) return  Float is
begin
return Float(V.X(P));
end F;

function G (M : Individual) return Float is
begin
return Float(V.X(M));
end G;

begin
g_search(P,Q,R);
end main_search;

This is in principle what I want to set up and run, while I want to be flexible in defining F and G and other parameters, without having to modify the files search.ads and search.adb. 

  parent reply	other threads:[~2014-06-20 17:39 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-20 15:18 Function definitions montgrimpulo
2014-06-20 15:44 ` Adam Beneschan
2014-06-20 16:22 ` montgrimpulo
2014-06-20 16:43   ` Adam Beneschan
2014-06-20 16:52     ` Simon Clubley
2014-06-20 17:05       ` Adam Beneschan
2014-06-20 16:43   ` Simon Clubley
2014-06-22  6:59   ` Shark8
2014-06-20 17:39 ` montgrimpulo [this message]
2014-06-20 18:19   ` Adam Beneschan
2014-06-20 18:20     ` Adam Beneschan
2014-06-21 20:56     ` Stephen Leake
2014-06-22 12:27     ` Simon Clubley
2014-06-20 20:39   ` Robert A Duff
2014-06-21 12:27 ` montgrimpulo
2014-06-21 12:38   ` Simon Clubley
2014-06-21 17:57   ` Jeffrey Carter
2014-06-21 13:40 ` montgrimpulo
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox