| Did you know ... | Search Documentation: |
| readln.pl -- Read line as list of tokens |
Read a sentence from the current input stream and convert it into a list of atoms and numbers:
The reader is flexible, you can define yourself:
character(s) that make up a word (execpt the
characters A-Z, a-z that always make up words!!
and (real)-numbers that always are grouped together!!)readln/1 The default setting for readln/1 is
underscore('_') and numbers 0-9 as part of wordscharacter(s):
instantiate argument 3 with the list of ASCII code's
of the desired stop characters (Note: you can also
say: ".!?", what is equivalent to [46,33,63]).character(s):
instantiate argument 4 with the list of ASCII code's
of the desired word-part characters (Note: wou can also
say: "", what is equivalent to [] ; i.e. no extra
characters).Main predicates provided:
readln(P) - Read a sentence up till NewLine and
unify <P> with the list of atoms/numbers
(identical to:
readln(P, [10],"_01213456789",uppercase).)
readln(P, LastCh) - idem as above but the second argument is unified
with the last character read (the ascii-code for
the stop-character or -1)
readln(P, LastCh, Arg1, Arg2, Arg3)
- idem as above but the default setting is changed
for the instantiated args:
Arg1: List of stop characters
Arg2: List of word_part characters
Arg3: uppercase/lowercase conversion
read_sentence(P,Case) :-
readln(P,_,".!?","_0123456789",Case).
read_in(P) :- % with numbers as separate
readln(P,Eof,_,"", _). % entities.
read_atom(A) :- % stop on newline,
readln(A,_,_," ",_). % space is part of word
The following predicates are exported, but not or incorrectly documented.