forked from saetre/busstuc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnaive.pl
More file actions
46 lines (30 loc) · 680 Bytes
/
naive.pl
File metadata and controls
46 lines (30 loc) · 680 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
%% FILE naive.pl
%% CREATED TA-921214
%% REVISED TA-980518
% Test Lips rate according to Naive Reverse
% set(... ==> aset( ... %% TA-960730
take_time(A):-
statistics(runtime,[A,_]). %%% SICSTUS 3.0
naive:-
write('N = '),read(N),
aset(N,X),
!,
take_time(A),
nreverse(X,_),
take_time(B),
C is B-A + 1,
write('Time '),write(C),write(' ms '),nl,
LIPS is floor(((N*(N+1)/2)/ (C ))*1000 ),
write('LIPS = '),write(LIPS),nl.
aset(0,[]):-!.
aset(N,[a|X]):-
M is N - 1,
aset(M,X).
nreverse([X|U],Z):-
nreverse(U,V),
append(V,[X],Z). % 1+ #V
nreverse([],[]).
%append([],X,X).
%append([X|Y],U,[X|V]):-
% append(Y,U,V).
%