![]() |
YAP 7.1.0
|
This package provides a set of useful predicates to manipulate sequences of characters codes, usually first read in as a line. More...
This package provides a set of useful predicates to manipulate sequences of characters codes, usually first read in as a line.
It is available by loading the
class search_for/2 |
search_for(+ Char,+ Line)
Search for a character Char in the list of codes Line
class scan_integer/3 |
scan_integer(? Int,+ Line,+ RestOfLine)
Scan the list of codes Line for an integer Nat, either a positive, zero, or negative integer, and unify RestOfLine with the remainder of the line
class integer/3 |
integer(? Int,+ Line,+ RestOfLine)
Scan the list of codes Line for an integer Nat, either a positive, zero, or negative integer, and unify RestOfLine with the remainder of the line
class scan_natural/3 |
scan_natural(? Nat,+ Line,+ RestOfLine)
Scan the list of codes Line for a natural number Nat, zero or a positive integer, and unify RestOfLine with the remainder of the line
class natural/3 |
natural(? Nat,+ Line,+ RestOfLine)
Scan the list of codes Line for a natural number Nat, zero or a positive integer, and unify RestOfLine with the remainder of the line
class skip_whitespace/2 |
skip_whitespace(+ Line,+ RestOfLine)
Scan the list of codes Line for white space, namely for tabbing and space characters
class blank/2 |
blank(+ Line,+ RestOfLine)
The list of codes Line is formed by white space, namely by tabbing and space characters
class split/2 |
split(+ Line,- Split)
Unify Words with a set of strings obtained from Line by using the blank characters as separators
class split/3 |
class split_unquoted/3 |
split_unquoted(+ Line,+ Separators,- Split)
Unify Words with a set of strings obtained from Line by using the character codes in Separators as separators, but treat text wi thin double quotes as a single unit As an example, consider:
class split_quoted/5 |
split_quoted(+ Line,+ Separators, GroupQuotes, SingleQuotes, - Split)
Unify Words with a set of strings obtained from Line by using the character codes in Separators as separators, but treat text within quotes as a single unit As an example, consider:
class fields/2 |
fields(+ Line,- Split)
Unify Words with a set of strings obtained from Line by using the blank characters as field separators
class fields/3 |
fields(+ Line,+ Separators,- Split)
Unify Words with a set of strings obtained from Line by using the character codes in Separators as separators for fields If two separators occur in a row, the field is considered empty As an example, consider:
class glue/3 |
glue(+ Words,+ Separator,- Line)
Unify Line with string obtained by glueing Words with the character code Separator
class copy_line/2 |
copy_line(+ StreamInput,+ StreamOutput)
Copy a line from StreamInput to StreamOutput
class filter/3 |
filter(+ StreamInp, + StreamOut, + Goal)
For every line LineIn in stream StreamInp, execute call(Goal,LineIn,LineOut)
, and output LineOut to stream StreamOut If call(Goal,LineIn,LineOut)
fails, nothing will be output but execution continues with the next line As an example, consider a procedure to select the second and fifth field of a CSV table :
class process/2 |
process(+ StreamInp, + Goal)
For every line LineIn in stream StreamInp, call call(Goal,LineIn)
meta
For every line LineIn in stream StreamInp, call call(Goal,LineIn)
class file_filter/3 |
file_filter(+ FileIn, + FileOut, + Goal)
meta
<em>FileIn</em> | File to process |
<em>FileOut</em> | Output file, often user_error |
<em>Goal</em> | to be metacalled, receives FileIn and FileOut as extra arguments |
For every line LineIn in file FileIn, execute call(Goal,LineIn,LineOut)
, and output LineOut to file FileOut
The input stream is accessible through the alias filter_input
, and the output stream is accessible through filter_output
class file_filter_with_initialization/5 |
file_filter_with_initialization(+ FileIn, + FileOut, + Goal, + FormatCommand, + Arguments)
Same as file_filter/3 , but before starting the filter execute format/3
on the output stream, using FormatCommand and Arguments
class file_filter_with_start_end/5 |
file_filter_with_start_end(+ FileIn, + FileOut, + Goal, + StartGoal, + EndGoal)
Same as file_filter/3 , but before starting the filter execute StartGoal, and call ENdGoal as an epilog
The input stream are always accessible through filter_output
and filter_input
class file_select/2 |
file_select(+ FileIn, + Goal)
meta
<em>FileIn</em> | File or Stream to process |
<em>Goal</em> | to be metacalled, receives FileIn as extra arguments |
call(
Goal,LineIn)`filter_input
, and the output stream is accessible through filter_output