-
Notifications
You must be signed in to change notification settings - Fork 0
/
truncate_between.pl
43 lines (30 loc) · 1.11 KB
/
truncate_between.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
%:-include('la_strings2.pl').
:-include('../listprologinterpreter/la_strings.pl').
:-include('../listprologinterpreter/la_strings_string.pl').
% word_count(["file","file.txt"],Words).
% Words = 69.
% word_count(["string","a b c"],Words).
% Words = 3.
% given file with number of As required and gl file length, gives div and mod values for t2b
truncate_between1(File1,Words_before,Words_during,File2) :-
Words_total is Words_before+Words_during,
SepandPad="&#@~%`$?-+*^,()|.:;=_/[]<>{}\n\r\s\t\\\"!'0123456789",
(true->
(phrase_from_file_s(string(String2), File1));
_String1=String2),
split_string(String2,SepandPad,SepandPad,String3),
%writeln(String3),
length(String3,Words2),
(Words_total>Words2->Words3=Words2;Words3=Words_total),
length(String4,Words3),
append(String4,_,String3),
length(String5a,Words_during),
append(_,String5a,String4),
findall([Item," "],member(Item,String5a),Item2),
maplist(append,[Item2],[Item3]),
concat_list(Item3,String5),
%term_to_atom(Item2,String4a),
%string_atom(String5,String4a),
(open_s(File2,write,Stream3),
write(Stream3,String5),
close(Stream3)),!.