[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: A ... question(s)
From: |
Vic Bancroft |
Subject: |
Re: A ... question(s) |
Date: |
Thu, 18 Jul 2002 09:27:21 -0400 (EDT) |
Consider the following for some one place predicate 'ax' which uses see/1 to
open a file as the standard input, reads each clause and asserts it if it is not
the end of file marker.
%%% -*- Mode: Prolog; -*-
dynamic( ax/1 ).
load_file( Name ) :-
see( Name ), read_all, seen.
read_all :-
read( Axiom ), assert_aux( Axiom ), read_all.
read_all.
assert_aux( end_of_file ) :- !, fail.
assert_aux( Axiom ) :- assertz( Axiom ).
In practice, you will want to handle syntax errors. So a bit of reading on
catch/3 might be helpful.
more,
l8r,
-------------------------------------------------------------------
Victor Bancroft, Principal Engineer, Zvolve Systems [v]770.551.4505
1050 Crown Pointe Pkwy, Suite 300, Atlanta GA 30338 [f]770.551.4509
Fellow, Artificial Intelligence Center [v]706.542-0358
Athens, Georgia 30602, U.S.A http://ai.uga.edu/~bancroft