Re: Help I'm stuck!
From: Pento (robby.goetschalckx_at_cs.kuleuven.ac.be.NOSPAM)
Date: 08/13/04
- Previous message: Pere Montolio: "Re: How to return clause in findall/3"
- In reply to: reader: "Re: Help I'm stuck!"
- Next in thread: reader: "Re: Help I'm stuck!"
- Reply: reader: "Re: Help I'm stuck!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 13 Aug 2004 09:25:02 +0000 (UTC)
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 ?
-- Pento De wereld was soep, en het denken meestal een vork, tot smakelijk eten leidde dat zelden. - H. Mulisch
- Previous message: Pere Montolio: "Re: How to return clause in findall/3"
- In reply to: reader: "Re: Help I'm stuck!"
- Next in thread: reader: "Re: Help I'm stuck!"
- Reply: reader: "Re: Help I'm stuck!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|