Re: ASSERT in SWI Prolog



Nick Wedd <nick@xxxxxxxxxxxxx> wrote:
In message <ebrnrb$deo$1@xxxxxxxxxxxxxxxx>, russell kym horsell
<kym@xxxxxxxxxxxxxxxxxxx> writes
Mika <miky821@xxxxxxxx> wrote:
I want to know if this can be made in SWI Prolog.
OK. The answer is "yes".
The answer to the question "is it pretty?", is -- of course -- "no".
It's not that ugly. Use bagof to collect all the facts into a list,
process the list to replace fact2 by fact6, retractall the facts, and
then assert the facts in the list. Though I can't imagine why anyone
would want to do this.

I was thinking FAR uglier. :)

I'm not sure bagof guarantees always to return the facts in the same
order asserted. Maybe on some implementations it could return them in
reverse order, for example.

But, yes, I was thinking along the same lines, with some partial evaluation
thrown in. ;)
.