From 9c54e6c7bbf503d63a6ff106d0373262841aecfb Mon Sep 17 00:00:00 2001 From: vsc Date: Thu, 28 Feb 2008 00:33:52 +0000 Subject: [PATCH] improve library git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@2122 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- library/lineutils.yap | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/library/lineutils.yap b/library/lineutils.yap index 44c6af6c3..ab47a9422 100644 --- a/library/lineutils.yap +++ b/library/lineutils.yap @@ -5,11 +5,13 @@ split/3, glue/3, filter/3, + file_filter/3, + process/2, copy_line/2, file_filter/3 ]). -:- meta_predicate filter(+,+,:). +:- meta_predicate filter(+,+,:), file_filter(+,+,:), process(+,:). :- use_module(library(lists), [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) :- open(Inp, read, StreamInp), open(Out, write, StreamOut),