Computing.Net > Forums > Programming > Prolog | Lists | anbody help

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Prolog | Lists | anbody help

Reply to Message Icon

Name: belfast
Date: May 17, 2006 at 12:45:37 Pacific
OS: win xp
CPU/Ram: 2.8 ghz
Product: dell
Comment:

I have an assignment to get handed in im already a week late.

i have a simple database in Win Prolog shown below. I have to ;

Use list rules to find the following,

All the unoccupied rooms
The number of occupied rooms
+
One additional Prolog rule and one additional list.

Please cane someone help i cannot grasp lists in prolog at all its wrecking my head.

I'd appreciate any help.

heres the database

/* DATABASE FOR HOSTEL, */
/* hostel_room(room_number, occupied_or_not, guest, booked_or_not, duration) */
/* */
hostel(1,occupied,edonaghy,no,5).
hostel(2,occupied,rwilson,no,7).
hostel(3,not_occupied,no,yes,none).
hostel(4,occupied,jcameron,no,14).
hostel(5,occupied,gmccourt,yes,3).
hostel(6,not_occupied,no,no,none).
hostel(7,occupied,idavis,no,5).
hostel(8,occupied,sreid,yes,7).
hostel(9,occupied,bdodds,no,14).
hostel(10,not_occupied,no,no,none).
hostel(11,occupied,etrainor,yes,2).
hostel(12,occupied,fcorrigan,no,1).
hostel(13,not_occupied,no,no,none).
hostel(14,occupied,dmccelland,yes,7).
hostel(15,occupied,tandrews,no,5).
hostel(16,occupied,rcorry,yes,14).
hostel(17,occupied,fleonard,no,3).
hostel(18,not_occupied,no,no,none).
hostel(19,not_occupied,no,no,none).
hostel(20,occupied,jmoore,yes,5).
hostel(21,occupied,cdrain,no,7).
hostel(22,occupied,pmonaghan,no,14).
hostel(23,occupied,bfarrell,yes,3).
hostel(24,occupied,wcarlin,no,2).
hostel(25,occupied,msimpson,no,3).
hostel(26,occupied,kcampbell,no,5).
hostel(27,occupied,vwelsh,yes,14).
hostel(28,occupied,nheaney,no,3).
hostel(29,not_occupied,no,no,none).
hostel(30,occupied,eohara,no,7).

/*Rules*/
guestNotBooked(GuestName):-hostel(_,_,GuestName,no,_).
occupiedRooms(RoomNumber,Guest):-hostel(RoomNumber,occupied,Guest,_,_).
roomsNotOccupied(RmNumber,OccupiedOrNot):-hostel(RmNumber,not_occupied,_,_,_).
roomNumbers(Room):-hostel(Room,_,_,_,_).



Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Prolog | Lists | anbody help

Help! Test if a number is Prime in C++ www.computing.net/answers/programming/help-test-if-a-number-is-prime-in-c/2794.html

VB 6.0 - List Box www.computing.net/answers/programming/vb-60-list-box/10590.html

Linked list www.computing.net/answers/programming/linked-list/6985.html