Re: Append to list

From: Pere Montolio (tmp123_at_menta.net)
Date: 08/12/04

  • Next message: rhapsody: "Re: How to return clause in findall/3"
    Date: 12 Aug 2004 00:29:24 -0700
    
    

    See inserted comments. Hope they useful.

    "rhapsody" <blurrynight@yahoo.com> wrote in message news:<7da0d8e77547715970941e3e9173d4a7@localhost.talkaboutprogramming.com>...
    > Can anybody give me clues of what is the correct way of appending node's
    > name to the output slist during the recursion of postOrder/2? I have
    > difficulties in getting the logic right. Below is the codes. Thanks!
    > Domains
    > btreeType = nil; btree(string, btreeType, btreeType)
    > slist = string*
    >
    > Predicates
    > nondeterm postOrder(btreeType, slist)
    > buildtree(btreeType)
    >
    > Clauses
    > postOrder(btree(Name,Tree1,Tree2), [H|T]) :-
    > postOrder(Tree1,T),
    > postOrder(Tree2,T),

    Two times T? It is not best T1 and T2 and append(T1,T2,T)?

    > write("Node : ", Name),

    Better: write("Node : "), write(Name), nl,

    > H = Name,

    > nl.
    >
    > postOrder(btree(Name,nil,nil), [H|T]) :-
    > write("Node : ",Name),
    > H = Name,
    > nl.

    T is free here. [H|T] must be changed by [H]?

    >
    > buildtree(Atree):-
    > T1 = btree(a, nil, nil),
    > T2 = btree(c, nil, nil),
    > T3 = btree(e, nil, nil),
    > T4 = btree(b, T1, T2),
    > Atree = btree(d, T4, T3).
    >
    > Goal
    > buildTree(Atree),postOrder(Atree,List),write("List : ", List).
    >
    > Regards,
    > Stanly


  • Next message: rhapsody: "Re: How to return clause in findall/3"

    Relevant Pages

    • RE: Undeliverable Email (pop3 connector)
      ... if you have found any clues. ... Good luck! ... Best regards, ... MCSE2000 MCDBA CCNA ...
      (microsoft.public.windows.server.sbs)
    • FC4 and No logs
      ... secure etc hasn't logged anything since yesterday. ... Anyone got any clues? ... With best regards ... Tomas Larsson ...
      (Fedora)
    • Help: Question on corrugated fibreboard
      ... There are several versions already on the market but they are not all ... that satisfactory. ... Any clues? ... Regards to all ...
      (sci.materials)
    • ODBC Bug in SQL Server 8?
      ... Any clues? ... Regards, ... Peter Arrenbrecht ... Opus Software AG ...
      (microsoft.public.sqlserver.odbc)
    • RE: New WebDAV Problems
      ... Please reproduce the error for several times and collect IIS log in ... We should be able to find clues from it. ... Best regards, ... WenJun Zhang ...
      (microsoft.public.inetserver.iis)