From: mheaney@ni.net (Matthew Heaney)
Subject: Re: "<" operator
Date: 1997/10/07
Date: 1997-10-07T00:00:00+00:00 [thread overview]
Message-ID: <mheaney-ya023680000710971821260001@news.ni.net> (raw)
In-Reply-To: 343A7434.36AD@newtimes.com
In article <343A7434.36AD@newtimes.com>, dperez <dperez@newtimes.com> wrote:
>how can I write a recursive Ada Function "<" that does the less-than
>comparison on linked lists of characters to do the obvious thing?
function "<"
(L, R : Character_List) return Boolean is
begin
if L = null then
if R = null then
return True;
else
raise <lists are not same length error>;
end if;
elsif R = null then
raise <lists are not same length error>;
else
return L.Item < R.Item and L.Next < R.Next;
end if;
end;
Won't that do it?
The type is
type Character_List_Node;
type Character_List is access Character_List_Node;
type Character_List_Node is
record
Item : Character;
Next : Character_List;
end record;
function "<" (L, R : Character_List) return Boolean;
--------------------------------------------------------------------
Matthew Heaney
Software Development Consultant
<mailto:matthew_heaney@acm.org>
(818) 985-1271
next prev parent reply other threads:[~1997-10-07 0:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-10-07 0:00 "<" operator dperez
1997-10-07 0:00 ` Matthew Heaney [this message]
1997-10-09 0:00 ` Mats Weber
-- strict thread matches above, loose matches on Subject: below --
1996-12-09 0:00 + Operator FREBOURG Fabrice
1996-12-10 0:00 ` Paul Chardon
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox