users-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: if


From: Calum Grant
Subject: RE: if
Date: Wed, 31 Jan 2001 09:32:24 -0000

A simpler variant of this problem is

        insert_set(H, L, L) :- member(H, L), !.  % A "hack" according to FH
        insert_set(H, L, [H|L]).

which takes an item H and inserts it into a list L without duplicates, like
a simple set.  The second clause should only be applied if the first one
fails.  Therefore the ! is necessary.  This can be rewritten as

        insert_set(H, S0, S) :-
        (
                member(H, S0) -> S0=S;  % A "hack" according to RS
                S = [H|S0]
        ).

The difference is purely cosmetic, and I don't think it's worth arguing
about.  It's a bit like saying that "|" is better than ";".

Calum
--
  Calum Grant - address@hidden - 01223 569700

The Information contained in this e-mail message is intended only for
the individuals named above. If you are not the intended recipient,
you should be aware that any dissemination, distribution, forwarding
or other duplication of this communication is strictly prohibited.
The views expressed in this e-mail are those of the individual
author and not necessarily those of Envisional Software Solutions Ltd.
Prior to taking any action based upon this e-mail message you should
seek appropriate confirmation of its authenticity. If you have
received this e-mail in error, please notify the sender immediately.



> -----Original Message-----
> From: address@hidden [mailto:address@hidden
> Behalf Of Ron Stodden
> Sent: Tuesday, January 30, 2001 6:39 PM
> To: address@hidden
> Subject: Re: if
>
>
> Fergus Henderson wrote:
> >
> > How would you write something simple like the following code, then?
>
> Simple?   What is the underlying operation this tries to achieve -
> say, expressed in simple English?   It is not at all apparent.
>
> --
> Regards,
>
> Ron. [AU]
>
> _______________________________________________
> Users-prolog mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/users-prolog
>
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]