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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,24d7acf9b853aac8 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!c10g2000yqi.googlegroups.com!not-for-mail From: Shark8 Newsgroups: comp.lang.ada Subject: Re: S-expression I/O in Ada Date: Thu, 12 Aug 2010 19:31:29 -0700 (PDT) Organization: http://groups.google.com Message-ID: <43ae2d00-20ab-4871-8ec3-9ad379d88955@c10g2000yqi.googlegroups.com> References: <547afa6b-731e-475f-a7f2-eaefefb25861@k8g2000prh.googlegroups.com> <203526c0-f031-4dfe-b3e0-cd5156de14b8@z28g2000yqh.googlegroups.com> NNTP-Posting-Host: 174.28.232.29 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1281666689 24573 127.0.0.1 (13 Aug 2010 02:31:29 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 13 Aug 2010 02:31:29 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: c10g2000yqi.googlegroups.com; posting-host=174.28.232.29; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 ( .NET CLR 3.5.30729; .NET CLR 4.0.20506),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:13199 Date: 2010-08-12T19:31:29-07:00 List-Id: Reading about the Cons-es I figure I should show how the constructs I made can be made exactly equivalent to a series of Cons-pairs. Unless I'm completely misunderstanding/misinterpreting the Lisp idea of a list being an item or an item followed by a list. Function Construct_Cons_Pair( Head, Tail : in Node_Type ) Return SExpression_Type is begin Return Result: SExpression_Type (List_Size => 2) do Result.List(1):= New SExpression_Type'( Create(Head) ); Result.List(2):= New SExpression_Type'( Create(Tail) ); end return; end Construct_Cons_Pair; Function Construct_Cons_Pair( Head : in Node_Type; Tail : in SExpression_Type) Return SExpression_Type is begin Case Tail.List_Size is When 0 => Return Construct_Cons_Pair( Head, Tail.Data.All ); When 1 => Return Construct_Cons_Pair( Head, Tail.List(1).All ); When Others => Return Result: SExpression_Type (List_Size => 2) do Result.List(1):= New SExpression_Type'( Create(Head) ); Result.List(2):= New SExpression_Type'( Tail ); end return; end case; end Construct_Cons_Pair; Function Is_Cons_Pair_Construct( S: in SExpression_Type ) Return Boolean is -- Perhaps this would be better named Is_Lisp_Construct.... begin Return ((S.List_Size = 2) And Then ((Not Is_List(S.List(1).All)) And Is_Cons_Pair_Construct( S.List(2).All ))) OR S.List_Size = 0; end Is_Cons_Pair_Construct; Maybe I should make a Construct_Cons_Pair( Head : in SExpression_Type; Tail : in Node_Type) for orthogonality's sake... but that would go against the Lisp-way.