Re: How to find persons who like red fruits or crunchy veggies?

From: Neo <neo55592_at_hotmail.com>
Date: 16 Nov 2006 21:27:05 -0800
Message-ID: <1163741224.981268.181900_at_j44g2000cwa.googlegroups.com>


> find pilots that can fly all airplanes

Following example finds pilots that fly all jets using selectAll function.

(new 'fly 'verb)

(new 'jet1 'jet)
(new 'jet2 'jet)

(new 'pilot1 'pilot)
(create pilot1 fly jet1)

(new 'pilot2 'pilot)
(create pilot2 fly jet1)
(create pilot2 fly jet2)

(; Find pilots who fly all jets)
(; Finds pilot2)
(and (select pilot instance *)

       (selectAll * fly (select jet instance *)))

(new 'jet3 'jet)
(new 'pilot3 'pilot)
(create pilot3 fly jet1)
(create pilot3 fly jet2)
(create pilot3 fly jet3)

(; Find pilots who fly all jets)
(; Finds pilot3)
(and (select pilot instance *)

       (selectAll * fly (select jet instance *)))

(new 'red 'color)
(create jet1 color red)

(new 'green 'color)
(create jet2 color green)

(new 'blue 'color)
(new 'purple 'color)
(create jet3 color blue)
(create jet3 color purple)

(; Find pilots who fly all jets that are red)
(; Finds pliot1, pilot2 and pilot3)
(and (select pilot instance *)

       (selectAll * fly (and (select jet instance *)
                             (select * color red))))

(; Find pilots who fly all jets that are green)
(; Finds pilot2 and pilot3)
(and (select pilot instance *)

       (selectAll * fly (and (select jet instance *)
                                   (select * color green))))

(; Find pilots who fly all jets that are blue and purple)
(; Finds pilot3)
(and (select pilot instance *)

       (selectAll * fly (and (select jet instance *)
                                   (select * color blue)
                                   (select * color purple))))

(; Find pilots who fly all jets that are red or green)
(; Finds pilot2 and pilot3)
(and (select pilot instance *)

       (selectAll * fly (and (select jet instance *)
                                   (select * color (or red green)))))
Received on Fri Nov 17 2006 - 06:27:05 CET

Original text of this message