Next: Terms, Previous: Builtin Introduction, Up: Built-Ins [Contents][Index]
Actions:
Write the elements of List
.
If the atom nl_
appears in List
it is written as a newline.
You can also use sp_(N)
where N is a positive integer to insert N spaces. Strings in List
are displayed without the string quotes ".." unless you write them with q_("...")
. The quotes are then put around the string.
writeL : (![??term]) ~>>
Example:
| ?? writeL(["List of atoms ",[a,b], nl_, "Set of nats ", {2,1,4,1}]). List of atoms [a, b] Set of nats {1, 2, 4}
with the next output on the next line.
nl_
causes a new line to be output as would the string "\n"
. In fact any of the C string control characters, such as "\t"
, "\s"
for tab and space respectively, can be put into a string and will have the intended effect unless the string is wrapped inside a q_
term. So we could have written the above query as:
| ?? writeL(["List of atoms ",[a,b], "\nSet of nats ", {2,1,4,1}]).
Other control term we can put in the list argument of writeL
are:
sp_(n)
, n positive integer. It will display n spaces.
uq_(Atom)
, where Atom
is an atom that normally needs to be quoted. It will be displayed without the single quotes.
wr_(Var)
, will not display Var
as an underscore followed by a sequence of digits, as is normal, but will give it a name such as A
, B
, C
when displayed and will give subsequent occurence of Var
in the list to be output using the given name for Var
.
The following query illustrates the the use of uq_
and wr_
.
| ?? writeL([uq_('Hello')," there\n",wr_(_895),sp_(2), _895,sp_(2),wr_(_678),nl_]). Hello there A A B _895 = A : Ty1 _678 = B : Ty2 success
The same as writeL
but with a trailing newline.
Example:
| ??writeLine([s("A list "), [a, b], sp_(2), {2, 1, 4, 1}, s(" followed by a set.")]). A list [a, b] {1, 2, 4} followed by a set.
with the next output being at the beginning of the next line.
Unifies Term
with the next term denoted by the next sequence
of characters typed at the terminal followed by fullstop, return.
readT :(term?) ~>>
Example:
| ?? readT(X). f(A). X = f(A) : term
Note that this read remembers the names of variables (the A
above).
A consequence of this, given the occurs check in unification, is that the
following query fails.
| ?? readT(A). f(A). no
Next: Terms, Previous: Builtin Introduction, Up: Built-Ins [Contents][Index]