improve library
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@2122 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
60b5042f09
commit
9c54e6c7bb
@ -5,11 +5,13 @@
|
|||||||
split/3,
|
split/3,
|
||||||
glue/3,
|
glue/3,
|
||||||
filter/3,
|
filter/3,
|
||||||
|
file_filter/3,
|
||||||
|
process/2,
|
||||||
copy_line/2,
|
copy_line/2,
|
||||||
file_filter/3
|
file_filter/3
|
||||||
]).
|
]).
|
||||||
|
|
||||||
:- meta_predicate filter(+,+,:).
|
:- meta_predicate filter(+,+,:), file_filter(+,+,:), process(+,:).
|
||||||
|
|
||||||
:- use_module(library(lists),
|
:- use_module(library(lists),
|
||||||
[member/2,
|
[member/2,
|
||||||
@ -81,6 +83,19 @@ filter(StreamInp, StreamOut, Command) :-
|
|||||||
).
|
).
|
||||||
|
|
||||||
|
|
||||||
|
process(StreamInp, Command) :-
|
||||||
|
repeat,
|
||||||
|
read_line_to_codes(StreamInp, Line),
|
||||||
|
(
|
||||||
|
Line == end_of_file
|
||||||
|
->
|
||||||
|
true
|
||||||
|
;
|
||||||
|
call(Command, Line),
|
||||||
|
fail
|
||||||
|
).
|
||||||
|
|
||||||
|
|
||||||
file_filter(Inp, Out, Command) :-
|
file_filter(Inp, Out, Command) :-
|
||||||
open(Inp, read, StreamInp),
|
open(Inp, read, StreamInp),
|
||||||
open(Out, write, StreamOut),
|
open(Out, write, StreamOut),
|
||||||
|
Reference in New Issue
Block a user