Re: Help I'm stuck!

From: reader (no-spam_at_sonic.net)
Date: 08/14/04

  • Next message: Pere Montolio: "Re: How to return clause in findall/3"
    Date: Fri, 13 Aug 2004 22:53:35 GMT
    
    

    Pento wrote:

    > reader <no-spam@sonic.net> wrote in
    > news:jGPSc.7175$54.109433@typhoon.sonic.net:
    >
    >
    >>/*
    >> You have declared your data to be a database, so just
    >>use retract to find the maximum score:
    >>*/
    >>
    >>Predicates
    >> find_max(integer,integer).
    >>
    >>Clauses
    >>
    >> find_max(In,Out) :-
    >> retract(sc(_,_,ExamScore)),
    >> !,
    >> elem_max(In,ExamScore,Next),
    >> find_max(Next,Out).
    >> find_max(In,In).
    >>
    >>GOAL find_max(0,Max).
    >
    >
    > I'm not a big fan of assert/retract, so I'm not sure of this, but shouln't
    > you assert the things you retracted again when the max is found ?
    >

       Your question was "Help I'm stuck, can anybody tell me how to
    retrieve sc() with the maximum score?". I showed one way of doing that
    using the code you wrote. Would you also like an egg in your beer?

    --
    

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