35 lines
		
	
	
		
			771 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			771 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | |
| %%
 | |
| %% simple constraint solver for inequalities between variables
 | |
| %% thom fruehwirth ECRC 950519, LMU 980207, 980311
 | |
| %%
 | |
| %% ported to hProlog by Tom Schrijvers 
 | |
| 
 | |
| :- module(leq,[]).
 | |
| :- use_module(library(chr)).
 | |
| 
 | |
| :- constraints leq/2.
 | |
| reflexivity  @ leq(X,X) <=> true.
 | |
| antisymmetry @ leq(X,Y), leq(Y,X) <=> X = Y.
 | |
| idempotence  @ leq(X,Y) \ leq(X,Y) <=> true.
 | |
| transitivity @ leq(X,Y), leq(Y,Z) ==> leq(X,Z).
 | |
| 
 | |
| t(N):-
 | |
| 	cputime(X),
 | |
| 	length(L,N),
 | |
| 	genleq(L,Last),
 | |
| 	L=[First|_],
 | |
| 	leq(Last,First),
 | |
| 	cputime( Now),
 | |
| 	Time is Now-X,
 | |
| 	write(N-Time), nl.
 | |
| 
 | |
| genleq([Last],Last) :- ! .
 | |
| genleq([X,Y|Xs],Last):-
 | |
| 	leq(X,Y),
 | |
| 	genleq([Y|Xs],Last).
 | |
| 
 | |
| cputime( Ts) :- 
 | |
| 	statistics( runtime, [Tm,_]),
 | |
| 	Ts is Tm/1000.
 |