Prolog Database?

Started by
3 comments, last by Anima 19 years, 11 months ago
I''m trying to create a searchable database in Prolog. Can someone explain how I can use a record containing (First Name, Second Name, Address) and then have multiple records to create a database? I know that Prolog isn''t the same as C/C++ but surely this can be done?
Advertisement
entry( jim, bean, '303 Main St, Hometown, SomeState' ).entry( jane, bean, '303 Main St, Hometown, SomeState' ).entry( billy, bean, 'The Slums, Hometown, SomeOtherState' ).addentry( Fn, Sn, Ad ):- assertz( entry( Fn, Sn, Ad ) ).delentry( Fn, Sn, Ad ):- revoke( entry( Fn, Sn, Ad ) ). 


And then, at an interactive prompt...

?> entry( A, bean, _ ).    jim    jane    billyYES?> entry( _, bean, _ ).YES?> entry( _, turnip, _ ).NO?> addentry( alex, turnip, 'DamnedIfIKnow' ).YES?> entry( A, B, _ ).    A = jim    B = bean    A = jane   B = bean    A = billy  B = bean    A = alex   B = turnipYES 


[edited by - Wyrframe on May 8, 2004 6:11:52 PM]
RIP GameDev.net: launched 2 unusably-broken forum engines in as many years, and now has ceased operating as a forum at all, happy to remain naught but an advertising platform with an attached social media presense, headed by a staff who by their own admission have no idea what their userbase wants or expects.Here's to the good times; shame they exist in the past.
Thanks for the reply, it really helped.

I''m now trying to make Prolog output a formatted number (for a time) to represent a time, for example:
write(H), write('':''), write(M), nl. 

If H = 12 and M = 5, then the output will be ''12:5''. Is there any way I can format this so it says ''12:05'' instead?

Thanks again
I don''t know prolog so no source for you but just use an if statement. If it''s less than ten, print an extra zero.
quote:Original post by Puzzler183
I don''t know prolog so no source for you but just use an if statement.

There are no ifs in Prolog. There are only buts

Sorry, I can''t help either. After finishing the mandatory Prolog course, I immediately purged all knowledge of Prolog from my brain, in an attempt to reclaim some basic sanity

This topic is closed to new replies.

Advertisement