Re: Storing data and code in a Db with LISP-like interface

From: Alvin Ryder <alvin321_at_telstra.com>
Date: 30 Apr 2006 18:46:00 -0700
Message-ID: <1146447960.027762.101450_at_y43g2000cwc.googlegroups.com>


Markus Triska wrote:
> Hi Alvin,
>
> Alvin Ryder wrote:
>
> >> Equating them is wrong.
> >
> > Why?
>
> Traditional Prolog includes features not considered pure by any stretch
> of the word (e.g. cut). Nick's examples are easy in traditional Prolog
> as well. Here is a pure version:
>
> likes(john, [apple,tomato,broccoli]).
>
> thing_is(apple, fruit, yes).
> thing_is(apple, vegetable, no).
> thing_is(broccoli, vegetable, yes).
> thing_is(broccoli, fruit, no).
> thing_is(tomato, vegetable, yes).
> thing_is(tomato, fruit, no).
>
> filter([], _, []).
> filter([Thing|Things], Class, [Thing|Fs]) :-
> thing_is(Thing, Class, yes),
> filter(Things, Class, Fs).
> filter([Thing|Things], Class, Fs) :-
> thing_is(Thing, Class, no),
> filter(Things, Class, Fs).
>
> Things John likes:
>
> ?- likes(john, Ls).
>
> Ls = [apple, tomato, broccoli]
>
>
> Fruits John likes:
>
> ?- likes(john, Ls), filter(Ls, fruit, Fs).
>
> Fs = [apple]
>
>
> Vegetables John likes:
>
> ?- likes(john, Ls), filter(Ls, vegetable, Vs).
>
> Vs = [tomato, broccoli]
>
>
> Does John like rice:
>
> ?- likes(John, Ls), member(rice, Ls).
>
> No
>
> This is entirely first-order.
>
> All the best,
> Markus.

Thanks for that Markus, I appreciate your time and the precision of your reply. Next time I will be more careful to differentiate between all the different versions, I once maintained that knowledge but it's all hazzy now. Same as Java, I can't remember what came when anymore (ok generics game in 1.5 ;-)

Cheers. Received on Mon May 01 2006 - 03:46:00 CEST

Original text of this message