From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e037d8cfeea3cca4 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-04-16 09:37:25 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!wn14feed!worldnet.att.net!216.196.106.140!border1.nntp.sjc.giganews.com!nntp.giganews.com!local1.nntp.sjc.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Fri, 16 Apr 2004 11:37:24 -0500 Date: Fri, 16 Apr 2004 12:37:24 -0400 From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Postfix notation with a binary Tree References: <970fcf2a.0404160512.4ad1d128@posting.google.com> In-Reply-To: <970fcf2a.0404160512.4ad1d128@posting.google.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <88idnWdjLZRZlh3dRVn-jw@comcast.com> NNTP-Posting-Host: 24.147.90.114 X-Trace: sv3-d4M3nFSFF+iGAIYUro7Wft+i1kAyyeeA0/l4ND2D3bVxAxKTF3Yto8jDnrDThRvhi9ZsCDNVGhLleB9!/7PTXu6V2BV/Qeg3c3ZAW9ShRwuJM84TWiPTZNZzfH7Q5SRMjtDkO1As/6vaRQ== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.1 Xref: archiver1.google.com comp.lang.ada:7214 Date: 2004-04-16T12:37:24-04:00 List-Id: tchou wrote: > Hello everyone, > > Which type should I use to do a binary tree for calculation, using a > postfix notation? > > '+' '-' -> character > 6876, 23.42, 1 -> Integer OR string > > Is a conversion to string the only / best solution? No, you can use either tagged types or variant records to create a heterogenous data structure. For this application I prefer variant records: type Content_Type is (Operator, Integer_Value, Float_Value, ...); type Node; type Node_Pointer is access all Node; type Node(Content: Content_Type) is record Left, Right: Node_Pointer; case Content_Type is when Operator => Op: Character; when Integer_Value => Int: Integer; ... end case; end record; -- Robert I. Eachus "The terrorist enemy holds no territory, defends no population, is unconstrained by rules of warfare, and respects no law of morality. Such an enemy cannot be deterred, contained, appeased or negotiated with. It can only be destroyed--and that, ladies and gentlemen, is the business at hand." -- Dick Cheney