Prolog Database?
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?
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]
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:
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''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
Popular Topics
Advertisement