%      Production system KORE/IE (version 12.48)
%
%          (C)1992 Institute for New Generation Computer Technology
%                          (Read COPYRIGHT for detailed information)
%
%      1992.7 Check and refine every programs 
%                             for IFS (ICOT Free Software) release.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% SYSTEM FUNCTOR %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/*
# compute  --- compute arithmetic expression
	USAGE:(compute Arithmetic_Expression).    	 % in production rule
	      (compute ^Answer,Arithmetic_Expression).   % at Top Level
# accept   --- read data from display or file
	USAGE:(accept).			  % input from current stream
						     in production rule
	      (accept File_Name).	  % input from file as 'File_Name'
						     in production rule
	      (accept ^Accept).		  % input from current stream
						     at Top Level
	      (accept ^Accept,File_Name). % input from file as 'File_Nmae'
						     at Top Level

*/

%%%%% COMPUTE
compute(X,A ^ B) :-
	!,
	compute(AX,A),
	!,
	compute(BX,B),
	X is AX ^ BX,
	!.
compute(X,A * B) :-
	!,
	compute(AX,A),
	!,
	compute(BX,B),
	X is AX * BX,
	!.
compute(X,A / B) :-
	!,
	compute(AX,A),
	!,
	compute(BX,B),
	X is AX / BX,
	!.
compute(X,A + B) :-
	!,
	compute(AX,A),
	!,
	compute(BX,B),
	X is AX + BX,
	!.
compute(X,A - B) :-
	!,
	compute(AX,A),
	!,
	compute(BX,B),
	X is AX - BX,
	!.
compute(X,User) :-
	User =.. [F|Atr],
	UserX =.. [F,X|Atr],
	!,
	UserX,
	!.
compute(X,X) :-
	number(X),
	!.

%%%%% ACCEPT
accept(X,File) :-
	atomic(File),
	seeing(Current_Stream),
	see(File),
	read(X),
	seen,
	see(Current_Stream).
accept(X,File) :-
	var(File),
	seeing(File),
	read(X).
accept(X) :-
	var(X),
	read(X).
