|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:
Some obscure 'rounding' is done, so you have most of the times only 6 significant digits with an exponent part. (This is caused by the system predicate 'name'. If you want looonnnggg numbers then define digits as parts of words). (N.B. reals work only if '.' is not defined as 'stop-char' but 'escape' will work in this case)
The reader is flexible, you can define yourself:
(this character is escapable with \ to read a \ type this character twice!!)
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!!)
underscore('_')and numbers 0-9 as part of words
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]).
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, ,"_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_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.