comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: How to use "infinite" ?
Date: Thu, 5 Jan 2006 13:16:20 +0100
Date: 2006-01-05T13:16:13+01:00	[thread overview]
Message-ID: <ckgbli1bp6gj$.1b2lhn1y2j3y2$.dlg@40tude.net> (raw)
In-Reply-To: jK6vf.3234$zc1.764@amstwist00

On Thu, 05 Jan 2006 11:42:22 +0100, Reinert Korsnes wrote:

> is it a natural way to use "infinite" in Ada95 ?

Which way, you didn't specify any!

> What I mean is that I would like a "number" X (= "infinite")
> such that:
> 
> (i + X = X) = true
> 
> for any normal (say) Integer i.

You should define an abstract data type to represent the set of integer
numbers + ideals you want (such as "negative infinity", "positive
infinity") . For example a universal package could be generic:

generic
   type Finite_Integer is range <>;
package Integers_With_Infinity_Ideals is
   type Infinite_Integer is private;
   --
   -- Unary operations
   --
   function "+" (Left : Infinite_Integer) return Infinite_Integer;
   function "-" (Left : Infinite_Integer) return Infinite_Integer;
   --
   -- Dyadic operations
   --
   function "+" (Left : Finite_Integer; Right : Infinite_Integer)
      return Infinite_Integer;
   function "+" (Left : Infinite_Integer; Right : Finite_Integer
      return Infinite_Integer;
   function "+" (Left, Right : Infinite_Integer)
      return Infinite_Integer;
   . . .
   --
   -- Relational operations
   --
   function "=" (Left : Finite_Integer; Right : Infinite_Integer)
      return Boolean;
   function "=" (Left : Infinite_Integer; Right : Finite_Integer
      return Boolean;
   function "=" (Left, Right : Infinite_Integer)
      return Boolean;
   . . .
private
   --
   -- Some appropriate implementation
   --
   . . .
end Integers_With_Infinity_Ideals;

BTW, for relational operations you could use tri-state logic:

   (infinity = infinity) = uncertain

instead of Boolean logic.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2006-01-05 12:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-05 10:42 How to use "infinite" ? Reinert Korsnes
2006-01-05 12:16 ` Dmitry A. Kazakov [this message]
2006-01-05 23:33   ` Gautier Write-only
2006-01-06 10:25     ` Reinert Korsnes
2006-01-06 14:38       ` Dmitry A. Kazakov
replies disabled

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