Original Post
🔒 Locked
Prolog Database?
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]
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.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement