Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Prolog Database?

This topic is 5124 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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
billy
YES
?> 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 = turnip
YES


[edited by - Wyrframe on May 8, 2004 6:11:52 PM]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!