Re: Out of local stack? (SWI)

From: djamé (djame_at_biensur.com)
Date: 01/14/04

  • Next message: pm: "Re: converting from numbers to letters"
    Date: Wed, 14 Jan 2004 23:36:55 +0100
    
    

    I've loooked in your code too and what you should consider is to check
    that your clauses go from the most spécific case to the most général
    one......rembember, order is very important in prolog (that's why peolpe
    who are coming from a imperative language love the
    ( test = x ->
       do_x
      ; test=y ->
        do_y
       ; test = z ->
        do_z
       ; % default
        do_defaults
       ). % I know I should add all the parenthesis but I'm tired now....

    in fact, maybe the first clause can match too much stuff....... so the
    use of the cut is justified if you consider that you have to check one
    and only one choice, so in order to debug maybe you shoulde add a cut to
    all the lines 'Ontimer" and see wich one is always choosen.....

    Djamé

    ps to respond : my email is djame.seddah@NOSPAM.loria.fr

    seguso wrote:
    > Il Thu, 01 Jan 2004 18:25:18 +0000, Jan Wielemaker ha scritto:
    >
    >
    >>This predicate should either be written using if-then-else style
    >>or after passing the conditions for the clause there should be a cut.
    >>Remember you only get last-call optimisation if *Prolog* understands there
    >>are no choicepoints, not if *you* can prove there is only one solution
    >>and standard Prolog is pretty simple minded.
    >
    >
    > Thanks a lot for the lesson. That theory is just what I needed (and I
    > have no idea where I could find it).
    >
    > I was assuming that tail-recursion was sufficient in order to have
    > last-call optimization... I am beginning to realize I don't have a good
    > background in prolog, only your reference manual :-)
    >
    >
    >>P.s. The screendumps of segusoland look nice!
    >
    >
    > Thanks! So the choice of using GTK was a good one. Looks are important
    > nowadays.
    >
    > ---
    >
    > Many have told me "What? it is not in C? too bad, I would have been
    > willing to help you if it were..."
    >
    > If i converted it to C I would have a huge list of helpers...
    >
    > But I know at least two persons who are studying prolog because of my
    > program. :-)
    >


  • Next message: pm: "Re: converting from numbers to letters"

    Relevant Pages

    • question about last call optimization
      ... I have a question about last call optimization using euclids algorithm ... Okay the prolog literature gives the procedure as: ... Now will prolog "last call optimize" this. ... What about if we switch the order of the clauses as such: ...
      (comp.lang.prolog)
    • Re: The Da Vinci Code.
      ... Prolog language which just don't stand up in practice. ... get experienced, you realize that most clauses *are*, in fact, ...
      (alt.usage.english)
    • Re: question about last call optimization
      ... Okay the prolog literature gives the procedure as: ... > no alternative clauses. ... then you still have last-call optimization in some Prolog systems (e.g., ...
      (comp.lang.prolog)
    • Re: Beginners questions
      ... > The above clause is OK, since there is no built-in predicate digit/1. ... clauses are ... truths, and prolog can the use these truths to deduce other truths. ...
      (comp.lang.prolog)