-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstrings.pl
75 lines (61 loc) · 1.29 KB
/
strings.pl
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
% Join two strings to form a new one
join(String1, String2, NewString) :-
name(String1, L1),
name(String2, L2),
append(L1, L2, NewList),
name(NewString, NewList).
readline(S) :-
readline1([], L),
name(S, L),
!.
readline1(OldList, L) :-
get0(X),
process(OldList, X, L).
process(OldList, 10, OldList).
process(OldList, X, L) :-
append(OldList, [X], L1),
readline1(L1, L).
readlineF(File, S) :-
see(File),
readline1([], L),
name(S, L),
!,
seen.
separate(List, Before, After) :-
append(Before, [32|After], List),
!.
findnext(L) :-
separate(L, Before, After),
proc(Before, After).
findnext(L):-
write('Last item is '),
name(S, L),
write(S),
nl.
proc(Before, After) :-
write('Next item is '),
name(S, Before),
write(S),
nl,
findnext(After).
splitup(S) :-
name(S, L),
findnext(L).
startList(L1, L2) :-
append(L1, _, L2).
includedList(_, []) :-
!,
fail.
includedList(L1, L2) :-
startList(L1, L2).
includedList(L1, [_|L2]) :-
includedList(L1, L2).
checkit(L, Plist, present) :-
includedList(Plist, L).
checkit(_, _, absent).
checkprolog(X) :-
readline(S),
name(S, L),
name('Prolog', Plist),
checkit(L, Plist, X),
!.